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

DeviceType.Desktop

建议修改

成功!

感谢您帮助我们提高 Unity 文档的质量。虽然我们无法采纳所有提交的内容,但我们会阅读用户提出的每一项修改建议,并在适用的情况下进行更新。

关闭

提交失败

由于某些原因,您的修改建议无法提交。请<a>稍后再试</a>。感谢您抽出时间帮助我们提高 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"; } } }