以后上报游戏数据的时候可能需要根据设备唯一id做新增用户的计算,如果直接使用Unity的API会不方便,代码风格不符合我们自己的框架。所以对获取设备ID、设备型号的API 封装了一下。
DeviceUtil.cs 代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
//获取设备标识符
public class DeviceUtil
{
//获取设备标识符
public static string DeviceIdentifier
{
get
{
return SystemInfo.deviceUniqueIdentifier;
}
}
//获取设备型号
public static string DeviceModel
{
get
{
#if !UNITY_EDITOR && UNITY_IPHONE
return UnityEngine.iOS.Device.generation.ToString();
#else
return SystemInfo.deviceModel;
#endif
}
}
}