From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XExtNativeInfo.cs | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Client/Assets/Scripts/XExtNativeInfo.cs (limited to 'Client/Assets/Scripts/XExtNativeInfo.cs') diff --git a/Client/Assets/Scripts/XExtNativeInfo.cs b/Client/Assets/Scripts/XExtNativeInfo.cs new file mode 100644 index 00000000..7484979d --- /dev/null +++ b/Client/Assets/Scripts/XExtNativeInfo.cs @@ -0,0 +1,67 @@ +using UnityEngine; +using System.Collections; +using System.Runtime.InteropServices; +using System; + +public class XExtNativeInfo +{ + + [DllImport("__Internal")] + private static extern int GetDensity(); + + [DllImport("__Internal")] + private static extern string CheckSIM(); + + + public static int U3DGetDensity() + { +#if UNITY_EDITOR + return 200; +#elif UNITY_ANDROID + int density = 200; + try + { + AndroidJavaClass jc = new AndroidJavaClass("com.act.hot1.tencent.SystemInfoActivity"); + AndroidJavaObject jo = jc.GetStatic("uniqueInstance"); + density = jo.Call("GetDensity"); + } + catch (Exception e) { Debug.Log("err: "+e.StackTrace); } + Debug.Log("android density is: " + density); + return density; +#elif UNITY_IOS + int density = GetDensity(); + Debug.Log("ios density is: " + density); + return density; +#else + return 200; +#endif + } + + + + public static string U3DGetSim() + { +#if UNITY_EDITOR + return ""; +#elif UNITY_ANDROID + string str = ""; + try + { + AndroidJavaClass jc = new AndroidJavaClass("com.act.hot1.tencent.SystemInfoActivity"); + AndroidJavaObject jo = jc.GetStatic("uniqueInstance"); + str = jo.Call("CheckSIM"); + } + catch (Exception e) { Debug.Log("err: " + e.StackTrace); } + Debug.Log("androidCheckSIM: " + str); + return str; +#elif UNITY_IOS + string str = CheckSIM(); + Debug.Log("ios CheckSIM: " + str); + return str; +#else + return ""; +#endif + + } + +} -- cgit v1.1-26-g67d0