三国卡牌客户端基础资源仓库
hch
9 天以前 0b904793cc85fbd661980b522a82f1281b827aa7
0312 获取设备相关信息改成android 和webgl各自获取
1个文件已修改
34 ■■■■ 已修改文件
Assets/Launch/Manager/LocalResManager.cs 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Launch/Manager/LocalResManager.cs
@@ -949,6 +949,21 @@
    }
#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();
@@ -968,12 +983,14 @@
    }
#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
    }
@@ -982,16 +999,19 @@
#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