版權聲明:本文為博主原創文章,未經博主允許不得轉載。
https://blog.csdn.net/u010377179/article/details/52618597
轉載請注明出處!
近期才發現Unity3D還有一個訪問硬件設備信息的類SystemInfo。
概述:
UnityEngine.SystemInfo類中的屬性都是只讀屬性,存儲着運行平台的一些硬件信息,找出底層平台和硬件的功能,如:設備的名稱、設備的類型、顯卡的類型,顯卡的名稱、顯卡供應商(制造商)、系統內存大小、顯存大小、支持的渲染目標數量等等。我們也可以檢查支持哪些RenderTexture(渲染紋理)格式(SupportsRenderTextureFormat),CPU有多少可用的線程的(processorCount)等等。
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屬性值。
官方文檔英文顯示:
copyTextureSupport | Support for various Graphics.CopyTexture cases (Read Only). |
deviceModel | The model of the device (Read Only). |
deviceName | The user defined name of the device (Read Only). |
deviceType | Returns the kind of device the application is running on (Read Only). |
deviceUniqueIdentifier | A unique device identifier. It is guaranteed to be unique for every device (Read Only). |
graphicsDeviceID | The identifier code of the graphics device (Read Only). |
graphicsDeviceName | The name of the graphics device (Read Only). |
graphicsDeviceType | The graphics API type used by the graphics device (Read Only). |
graphicsDeviceVendor | The vendor of the graphics device (Read Only). |
graphicsDeviceVendorID | The identifier code of the graphics device vendor (Read Only). |
graphicsDeviceVersion | The graphics API type and driver version used by the graphics device (Read Only). |
graphicsMemorySize | Amount of video memory present (Read Only). |
graphicsMultiThreaded | Is graphics device using multi-threaded rendering (Read Only)? |
graphicsShaderLevel | Graphics device shader capability level (Read Only). |
maxTextureSize | Maximum texture size (Read Only). |
npotSupport | What NPOT (non-power of two size) texture support does the GPU provide? (Read Only) |
operatingSystem | Operating system name with version (Read Only). |
processorCount | Number of processors present (Read Only). |
processorFrequency | Processor frequency in MHz (Read Only). |
processorType | Processor name (Read Only). |
supportedRenderTargetCount | How many simultaneous render targets (MRTs) are supported? (Read Only) |
supports2DArrayTextures | Are 2D Array textures supported? (Read Only) |
supports3DTextures | Are 3D (volume) textures supported? (Read Only) |
supportsAccelerometer | Is an accelerometer available on the device? |
supportsAudio | Is there an Audio device available for playback? |
supportsComputeShaders | Are compute shaders supported? (Read Only) |
supportsGyroscope | Is a gyroscope available on the device? |
supportsImageEffects | Are image effects supported? (Read Only) |
supportsInstancing | Is GPU draw call instancing supported? (Read Only) |
supportsLocationService | Is the device capable of reporting its location? |
supportsMotionVectors | Are motion vectors supported. |
supportsRawShadowDepthSampling | Is sampling raw depth from shadowmaps supported? (Read Only) |
supportsRenderTextures | Are render textures supported? (Read Only) |
supportsRenderToCubemap | Are cubemap render textures supported? (Read Only) |
supportsShadows | Are built-in shadows supported? (Read Only) |
supportsSparseTextures | Are sparse textures supported? (Read Only) |
supportsStencil | Is the stencil buffer supported? (Read Only) |
supportsVibration | Is the device capable of providing the user haptic feedback by vibration? |
systemMemorySize | Amount of system memory present (Read Only). |
unsupportedIdentifier | Value returned by SystemInfo string properties which are not supported on the current platform. |
SystemInfo類中的函數:
bool SupportsRenderTextureFormat(
RenderTextureFormat format);
輸入一個渲染紋理的格式,判斷設備是否支持這種格式
bool SupportsTextureFormat(
TextureFormat format);
輸入一個紋理的格式,判斷設備是否支持這種格式。