获取运行设备硬件信息(CPU、显卡、类型等)可用于手机
UnityEngine.SystemInfo类中的属性都是只读属性,存储着运行平台的一些硬件信息,找出底层平台和硬件的功能,如:设备的名称、设备的类型、显卡的类型,显卡的名称、显卡供应商(制造商)、系统内存大小、显存大小、支持的渲染目标数量等等。我们也可以检查支持哪些RenderTexture(渲染纹理)格式(SupportsRenderTextureFormat),CPU有多少可用的线程的(processorCount)等等。
| SystemInfo类中的静态变量 | ||
|---|---|---|
| float | batteryLevel | 当前电池电量 |
| BatteryStatus | batteryStatus | 返回设备电池的当前状态 |
| 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 | graphicsPixelFillrate | 图形像素填充 |
| 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属性值 |
| bool | usesReversedZBuffer | 如果当前平台使用相反的深度缓冲区(其中值在近平面为1,远平面为0,则为true),则该属性为真,如果深度缓冲区正常(0近于1,则为远) |
SystemInfo类中的函数:
//输入一个渲染纹理的格式,判断设备是否支持这种格式
bool SupportsRenderTextureFormat(RenderTextureFormat format);
//输入一个纹理的格式,判断设备是否支持这种格式。
bool SupportsTextureFormat(TextureFormat format);
本文介绍如何使用UnityEngine.SystemInfo类来获取Unity运行设备的硬件信息,包括设备型号、名称、类型、显卡信息、处理器信息、内存大小等。还介绍了如何检查设备支持的渲染特性。

638

被折叠的 条评论
为什么被折叠?



