Read PC hardware information in Unity---SystemInfo

Unity3D's SystemInfo class is used to obtain running device hardware information (CPU, graphics card, type, etc.)
Static variables in SystemInfo class:
Rendering.CopyTextureSupport copyTextureSupport: (read-only) Supports multiple cases of copy texture functionality.
string deviceModel: (read-only) device model (the device model written in many posts is very misleading).
string deviceName: (Read-only) User-defined device name.
DeviceType deviceType: (Read-only) Returns the device type on which the program is running (PC, handheld, etc.).
string deviceUniqueIdentifier: (Read-only) The unique identifier of the device. Each device has a unique identifier.
int graphicsDeviceID: (read-only) The unique identifier ID of the graphics card.
string graphicsDeviceName: (Read-only) The name of the graphics card.
Rending.GraphicsDeviceType graphicsDeviceType: (read-only) The type of graphics card.
string graphicsDeviceVendor: (Read-only) The vendor of the graphics card.
int graphicsDeviceVendorID: (read-only) The unique identification code ID of the graphics card vendor.
string graphicsDeviceVersion: (Read-only) Type and version of the graphics card.
int graphicsMemorySize: (read-only) graphics memory size.
bool graphicsMultiThreaded: (read-only) Is multi-threaded rendering supported?
int graphicsShaderLevel: (read-only) The level of the graphics shader.
int maxTextureSize: (read-only) Maximum supported texture size.
NPOTSupport npotSupport: (read-only) NPOT textures supported by the GPU.
string operatingSystem: (Read-only) The version name of the operating system.
int processorCount: (read-only) The number of current processors.
int processorFrequency: (read-only) processor frequency.
string processorType: (Read-only) The name of the processor.
int supportedRenderTargetCount: (read-only) How many target textures are supported for rendering.
bool supports2DArrayTextures: (read-only) Whether to support 2D array textures.
bool supports3DTextures: (read-only) Whether to support 3D (volume) textures.
bool supportsAccelerometer: (read-only) Whether to support obtaining the accelerometer.
bool supportsAudio: (read-only) Whether to support obtaining audio devices for playback.
bool supportsComputeShaders: (read-only) Whether to support compute shaders.
bool supportsGyroscope: Whether to support obtaining gyroscope.
bool supportsImageEffects: (read-only) whether to support graphic effects.
bool supportsInstancing: (read-only) Whether to support the Draw Call of instantiated GPU.
bool supportsLocationService: Whether the location function is supported.
bool supportsMotionVectors: Whether to support motion vectors.
bool supportsRawShadowDepthSampling: (read-only) Whether to support shadow depth.
bool supportsRenderTextures: (read-only) Whether to support rendering textures.
bool supportsRenderToCubemap: (read-only) Whether to support cube textures.
bool supportsShadows: (read-only) Whether to support built-in shadows.
bool supportsSparseTextures: (read-only) Whether to support sparse textures.
bool supportsStencil: (read-only) whether to support template caching.
bool supportsVibration: Whether to support user touch vibration feedback.
int systemMemorySize: (read-only) system memory size.
string unsupportedIdentifier: The SystemInfo attribute value running on the current device is not supported.
Functions in SystemInfo class:
bool SupportsRenderTextureFormat(RenderTextureFormat format);
Enter a rendering texture format to determine whether the device supports this format.
 
bool SupportsTextureFormat(TextureFormat format);
Enter the format of a texture and determine whether the device supports this format.
Unity implements some of the functional codes as follows:
 
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GetcpuNum: MonoBehaviour
{
    //指定输出文本框
    public UnityEngine.UI.Text messageText;

    //存储临时字符串
    System.Text.StringBuilder info = new System.Text.StringBuilder();

    // Use this for initialization
    void Start()
    {
        //将输出文本框置空
        messageText.text = "";

        info.AppendLine("设备与系统信息:");


        //设备的模型
        GetMessage("设备模型",SystemInfo.deviceModel);

        //设备的名称
        GetMessage("设备名称",SystemInfo.deviceName);

        //设备的类型
        GetMessage("设备类型(PC电脑,掌上型)",SystemInfo.deviceType.ToString());

        //系统内存大小
        GetMessage("系统内存大小MB",SystemInfo.systemMemorySize.ToString());

        //操作系统
        GetMessage("操作系统",SystemInfo.operatingSystem);

        //设备的唯一标识符
        GetMessage("设备唯一标识符",SystemInfo.deviceUniqueIdentifier);

        //显卡设备标识ID
        GetMessage("显卡ID",SystemInfo.graphicsDeviceID.ToString());

        //显卡名称
        GetMessage("显卡名称", SystemInfo.graphicsDeviceName);

        //显卡类型
        GetMessage("显卡类型",SystemInfo.graphicsDeviceType.ToString());

        //显卡供应商
        GetMessage("显卡供应商", SystemInfo.graphicsDeviceVendor);

        //显卡供应唯一ID
        GetMessage("显卡供应唯一ID", SystemInfo.graphicsDeviceVendorID.ToString());

        //显卡版本号
        GetMessage("显卡版本号",SystemInfo.graphicsDeviceVersion);

        //显卡内存大小
        GetMessage("显存大小MB",SystemInfo.graphicsMemorySize.ToString());

        //显卡是否支持多线程渲染
        GetMessage("显卡是否支持多线程渲染",SystemInfo.graphicsMultiThreaded.ToString());

        //支持的渲染目标数量
        GetMessage("支持的渲染目标数量", SystemInfo.supportedRenderTargetCount.ToString());

        //输出
        messageText.text = info.ToString();

    }

    void GetMessage(params string[] str)
    {
        if(str.Length==2)

        {
            info.AppendLine(str[0]+":"+str[1]);
        }
    }  
}

running result:

 

Guess you like

Origin blog.csdn.net/u013774978/article/details/129847159