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

Device.generation

建议更改

成功!

感谢你帮助我们提升 Unity 文档质量。虽然我们无法接受所有提交,但我们会阅读每一条用户建议的变化,并在适用时进行更新。

关闭

提交失败

由于某种原因,无法提交你建议的更改。请重试几次。感谢你花时间帮我们提升 Unity 文档质量。

关闭

取消

public static iOS.DeviceGeneration generation;

描述

设备的世代。(只读)

有关可能值的详细信息,请参阅DeviceGeneration

using UnityEngine;
using UnityEngine.iOS;

public class DeviceGenerationExample : MonoBehaviour { string m_DeviceGeneration = "Undefined";

void Start() { // Check if the device running this is an "iPhone 14 Pro Max" if (Device.generation == DeviceGeneration.iPhone14ProMax) { m_DeviceGeneration = "iPhone 14 Pro Max"; } // Check if the device running this is an 'iPad Mini (6th generation)" if (Device.generation == DeviceGeneration.iPadMini6Gen) { m_DeviceGeneration = "iPad Mini (6th generation)"; } // Check if the device running this is an "iPod Touch (7th generation)" if (Device.generation == DeviceGeneration.iPodTouch7Gen) { m_DeviceGeneration = "iPod Touch (7th generation)"; }

// Check if the device running this is an unknown iPhone if (Device.generation == DeviceGeneration.iPhoneUnknown) { m_DeviceGeneration = "Unknown iPhone"; } // Check if the device running this is an unknown iPad if (Device.generation == DeviceGeneration.iPadUnknown) { m_DeviceGeneration = "Unknown iPad"; } // Check if the device running this is an unknown iPod Touch if (Device.generation == DeviceGeneration.iPodTouchUnknown) { m_DeviceGeneration = "Unknown iPod Touch"; } // Output the device generation to the console/device log Debug.Log("Device generation: " + m_DeviceGeneration); } }