12345678910111213141516171819202122232425 |
- using UnityEngine;
- namespace GFGGame
- {
- public class DeviceUniqueIdHelper
- {
- private const string UniqueIdentifierKey = "UniqueIdentifier";
- public static string GetDeviceUniqueId()
- {
- // 尝试从本地存储中获取唯一标识符
- string uniqueIdentifier = PlayerPrefs.GetString(UniqueIdentifierKey);
- // 如果本地存储中不存在唯一标识符,生成一个新的唯一标识符
- if (string.IsNullOrEmpty(uniqueIdentifier))
- {
- uniqueIdentifier = SystemInfo.deviceUniqueIdentifier;
- // 将唯一标识符存储到本地存储中
- PlayerPrefs.SetString(UniqueIdentifierKey, uniqueIdentifier);
- }
-
- return PlayerPrefs.GetString(UniqueIdentifierKey);
- }
- }
- }
|