12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using UnityEngine;
- public class DeviceSN : MonoSingleton<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;
- }
- }
|