| | |
| | | } |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // WebGL 无设备级唯一标识,首次生成随机 GUID 并持久化到浏览器 localStorage(PlayerPrefs 底层), |
| | | // 之后直接复用,保证同一浏览器同一域名下统计去重稳定;清缓存/无痕/换浏览器会重新生成。 |
| | | public const string WebGLDeviceIdPrefKey = "webgl_device_unique_id"; |
| | | private static string GetOrCreateWebGLDeviceId() |
| | | { |
| | | var id = PlayerPrefs.GetString(WebGLDeviceIdPrefKey, string.Empty); |
| | | if (string.IsNullOrEmpty(id)) |
| | | { |
| | | id = System.Guid.NewGuid().ToString("D"); |
| | | PlayerPrefs.SetString(WebGLDeviceIdPrefKey, id); |
| | | PlayerPrefs.Save(); |
| | | } |
| | | return id; |
| | | } |
| | | |
| | | private async UniTaskVoid SendLauchEventAsync(int _step) |
| | | { |
| | | var versionConfig = await VersionConfigEx.Get(); |
| | |
| | | } |
| | | #endif |
| | | |
| | | public static string GetDeviceModel() |
| | | public static string GetDeviceUniquenessIdentify() |
| | | { |
| | | #if UNITY_IOS |
| | | return UnityEngine.iOS.Device.generation.ToString(); |
| | | return UnityEngine.iOS.Device.advertisingIdentifier; |
| | | #elif UNITY_WEBGL |
| | | return GetWebGLDeviceId(); |
| | | #else |
| | | return SystemInfo.deviceModel; |
| | | return UnityEngine.SystemInfo.deviceUniqueIdentifier; |
| | | #endif |
| | | } |
| | | |
| | |
| | | #if UNITY_IOS |
| | | return UnityEngine.iOS.Device.systemVersion; |
| | | #else |
| | | return SystemInfo.operatingSystem; |
| | | // WebGL 上返回浏览器 User-Agent 中解析出的操作系统信息(如 "Windows NT 10.0; Win64; x64") |
| | | return UnityEngine.SystemInfo.operatingSystem; |
| | | #endif |
| | | } |
| | | |
| | | public static string GetDeviceUniquenessIdentify() |
| | | |
| | | public static string GetDeviceModel() |
| | | { |
| | | #if UNITY_IOS |
| | | return UnityEngine.iOS.Device.advertisingIdentifier; |
| | | return UnityEngine.iOS.Device.generation.ToString(); |
| | | #else |
| | | return SystemInfo.deviceUniqueIdentifier; |
| | | // WebGL 上返回浏览器名称及版本(如 "Chrome 120.0.0.0"),并非真实硬件型号 |
| | | return UnityEngine.SystemInfo.deviceModel; |
| | | #endif |
| | | } |
| | | #endregion |