Version: 2023.2

SystemInfo.operatingSystem

切换到手册
public static string operatingSystem ;

描述

包含版本的操作系统名称(只读)。

返回有关设备操作系统的详细信息,包括版本。对于简单的平台检测,使用 Application.platformdeviceType 等属性可能更加合适。

Note: On Microsoft Store Apps, it's not easy to identify if you're running 32-bit or 64-bit version of Windows. However, you can query the CPU architecture to find this information. If the CPU is 64-bit, SystemInfo.operatingSystem returns Windows <version> 64 bit, and if the CPU is 32-bit - Windows <version>.

using UnityEngine;

public class ExampleClass: MonoBehaviour { void Start() { // Prints "Windows 11 (10.0.22621) 64bit" on 64 bit Windows 11 // Prints "Mac OS X 13.4" on Mac OS Ventura // Prints "iPhone OS" with iOS 15.3.1 // Prints "iPad OS" on iPad with iOS 16 // Prints "Android OS 13 / API-33 (TQ2A.230305.008.C1/9619669)" Debug.Log(SystemInfo.operatingSystem); } }

另请参阅:Application.platformdeviceType