版本:Unity 6 (6000.0)
语言英语
  • C#

DeviceType.Handheld

提出变更

成功!

感谢您帮助我们提升 Unity 文档的质量。尽管我们无法接受所有提交内容,但我们确实会阅读用户提出的每项建议变更,并在适用时进行更新。

关闭

提交失败

由于某些原因,无法提交您建议的变更。请在几分钟后重试。感谢您抽出时间,帮助我们提升 Unity 文档的质量。

关闭

取消

说明

类似于手机或平板电脑的便携式设备。

//Attach this script to a GameObject
//This script checks what device type the Application is running on and outputs this to the console

using UnityEngine;

public class DeviceTypeExample : MonoBehaviour { //This is the Text for the Label at the top of the screen string m_DeviceType;

void Update() { //Output the device type to the console window Debug.Log("Device type : " + m_DeviceType);

//Check if the device running this is a console if (SystemInfo.deviceType == DeviceType.Console) { //Change the text of the label m_DeviceType = "Console"; }

//Check if the device running this is a desktop if (SystemInfo.deviceType == DeviceType.Desktop) { m_DeviceType = "Desktop"; }

//Check if the device running this is a handheld if (SystemInfo.deviceType == DeviceType.Handheld) { m_DeviceType = "Handheld"; }

//Check if the device running this is unknown if (SystemInfo.deviceType == DeviceType.Unknown) { m_DeviceType = "Unknown"; } } }