123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using SC.XR.Unity.Module_Device;
- using System;
- using UnityEngine;
- public class DeviceSN : Singleton<DeviceSN>
- {
- private string serial;
-
-
-
-
- public long SendSerial()
- {
- AndroidJavaObject jo = new AndroidJavaObject("android.os.Build");
- serial = jo.GetStatic<string>("SERIAL");
- return SubStringDefault(serial);
- }
- public string SendSerialBy16()
- {
-
-
- #if UNITY_EDITOR
- return "ABD1234561";
- #elif UNITY_ANDROID
- return Convert.ToString(DeviceSN.Instance.SendSerial(), 16);
- #endif
- }
-
-
-
-
-
-
-
- public string SubStringByEnd(string str, int index, int length)
- {
- return str.Substring((index - length) < 0 ? 0 : (index - length), length);
- }
-
-
-
-
-
- public long SubStringDefault(string str)
- {
- bool r = long.TryParse(SubStringByEnd(str, str.Length, 10), out long result);
- if (!r)
- {
- Debug.LogError($"获取TagID失败 : {result}");
- }
- return result;
- }
- public string GetSn()
- {
- #if UNITY_EDITOR
- return "ABD1234561";
- #elif UNITY_ANDROID
- AndroidJavaObject jo = new AndroidJavaObject("android.os.Build");
- serial = jo.GetStatic<string>("SERIAL");
- return serial;
- #endif
- return Module_Device.getInstance.Current.SN;
- }
- }
|