前言:一般在MMORPG游戏的开发过程中,会在新注册或者登陆的时候,获取玩家设备标识符和设备型号。
一、直接给出脚本
using UnityEngine;
public class DeviceUtil
{
/// <summary>
/// 获取设备标识符
/// </summary>
public static string DeviceIdentifier
{
get
{
return SystemInfo.deviceUniqueIdentifier;
}
}
/// <summary>
/// 获取设备型号
/// </summary>
public static string DeviceModel
{
get
{
#if UNITY_IPHONE && !UNITY_EDITOR
return Device.generation.ToString();;
#else
return SystemInfo.deviceModel;
#endif
}
}
}
其中,关于设备型号DeviceModel。如果是电脑或者安卓设备,使用SystemInfo.deviceModel就能得到设备型号。但是苹果不一样,所以需要利用宏,使用Device.generation.ToString()方法得到设备型号。