Unity中读取Pc的硬件信息---SystemInfo

文章介绍了Unity3D中的SystemInfo类,该类提供了获取运行设备硬件信息的方法,如CPU、显卡、设备类型等详细参数。示例代码展示了如何使用SystemInfo获取并显示设备的相关信息,包括设备模型、设备名称、系统内存大小、显卡信息等。
摘要由CSDN通过智能技术生成
Unity3D的SystemInfo类,用于获取运行设备硬件信息(CPU、显卡、类型等)
SystemInfo类中的静态变量:
Rendering.CopyTextureSupport copyTextureSupport:(只读)支持多种复制纹理功能的情况。
string  deviceModel:(只读)设备型号(看到好多帖子都写的设备模型很让人误解)。
string  deviceName:(只读)用户定义的设备名称。
DeviceType  deviceType:(只读)返回程序运行所在的设备类型(PC电脑、掌上型等)。
string  deviceUniqueIdentifier:(只读)设备的唯一标识符。每一台设备都有唯一的标识符。
int   graphicsDeviceID:(只读)显卡的唯一标识符ID。
string  graphicsDeviceName:(只读)显卡的名称。
Rending.GraphicsDeviceType  graphicsDeviceType:(只读)显卡的类型。
string   graphicsDeviceVendor:(只读)显卡的供应商。
int   graphicsDeviceVendorID:(只读)显卡供应商的唯一识别码ID。
string   graphicsDeviceVersion:(只读)显卡的类型和版本。
int   graphicsMemorySize:(只读)显存大小。
bool  graphicsMultiThreaded:(只读)是否支持多线程渲染?
int   graphicsShaderLevel:(只读)显卡着色器的级别。
int   maxTextureSize:(只读)支持的最大纹理大小。
NPOTSupport  npotSupport:(只读)GPU支持的NPOT纹理。
string  operatingSystem:(只读)操作系统的版本名称。
int   processorCount:(只读)当前处理器的数量。
int   processorFrequency:(只读)处理器的频率。
string  processorType:(只读)处理器的名称。
int   supportedRenderTargetCount:(只读)支持渲染多少目标纹理。
bool  supports2DArrayTextures:(只读)是否支持2D数组纹理。
bool  supports3DTextures:(只读)是否支持3D(体积)纹理。
bool  supportsAccelerometer:(只读)是否支持获取加速度计。
bool  supportsAudio:(只读)是否支持获取用于回放的音频设备。
bool  supportsComputeShaders:(只读)是否支持计算着色器。
bool  supportsGyroscope:是否支持获取陀螺仪。
bool  supportsImageEffects:(只读)是否支持图形特效。
bool  supportsInstancing:(只读)是否支持实例化GPU的Draw Call。
bool  supportsLocationService:是否支持定位功能。
bool  supportsMotionVectors:是否支持运动向量。
bool  supportsRawShadowDepthSampling:(只读)是否支持阴影深度。
bool  supportsRenderTextures:(只读)是否支持渲染纹理。
bool  supportsRenderToCubemap:(只读)是否支持立方体纹理。
bool  supportsShadows:(只读)是否支持内置阴影。
bool  supportsSparseTextures:(只读)是否支持稀疏纹理。
bool  supportsStencil:(只读)是否支持模版缓存。
bool  supportsVibration:是否支持用户触摸震动反馈。
int   systemMemorySize:(只读)系统内存大小。
string   unsupportedIdentifier:不支持运行在当前设备的SystemInfo属性值。
SystemInfo类中的函数:
bool SupportsRenderTextureFormat(RenderTextureFormat format);
输入一个渲染纹理的格式,判断设备是否支持这种格式
 
bool SupportsTextureFormat(TextureFormat format);
输入一个纹理的格式,判断设备是否支持这种格式。
Unity实现部分功能代码如下:
 
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]);
        }
    }  
}

运行效果:

 

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GarFe-Liu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值