我想知道移动设备(如iPhone X(的统一。
https://www.theiphonewiki.com/wiki/Models
我通过这段代码知道在 Unity 上运行的设备是否是 iPhone X......
if ( SystemInfo.deviceModel == “iPhone10,3”
|| SystemInfo.deviceModel == “iPhone10,6”)
但是,我怎么知道设备是三星Galaxy S9还是LG V30?
使用相同的函数。
系统信息设备型号
https://docs.unity3d.com/ScriptReference/SystemInfo-deviceModel.html
Unity 还可以识别您的操作系统(操作系统(。因此,您可以识别何时是Android设备,iOS设备或Windows平台,即使您在Unity编辑器上运行也是如此。
如果您正在开发VR,您还可以识别XR设备,例如Oculus,HTC,Cardboard等设备。
使用 Systeminfo 类来确定底层平台和硬件的功能。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SystemInfoScript : MonoBehaviour
{
[SerializeField]
Text info;
string infoString = "";
// Start is called before the first frame update
void Start()
{
infoString += "Battery Level: " + SystemInfo.batteryLevel + "n";
infoString += "Battery Status: " + SystemInfo.batteryStatus + "n";
infoString += "Device Model: " + SystemInfo.deviceModel + "n";
infoString += "Device Name: " + SystemInfo.deviceName + "n";
infoString += "Device Type: " + SystemInfo.deviceType + "n";
infoString += "Device Unique Identifier: " + SystemInfo.deviceUniqueIdentifier + "n";
infoString += "Operating System: " + SystemInfo.operatingSystem + "n";
infoString += "Processor Type: " + SystemInfo.processorType + "n";
infoString += "Memory Size: " + SystemInfo.systemMemorySize + "n";
infoString += "Acceleromer Support: " + SystemInfo.supportsAccelerometer + "n";
infoString += "Gyroscope Support: " + SystemInfo.supportsGyroscope + "n";
infoString += "Vibration Support: " + SystemInfo.supportsVibration + "n";
info.text = infoString;
// For more: https://docs.unity3d.com/ScriptReference/SystemInfo.html
}
// Update is called once per frame
void Update()
{
}
}
更多: https://docs.unity3d.com/ScriptReference/SystemInfo.html