summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XExtNativeInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assets/Scripts/XExtNativeInfo.cs')
-rw-r--r--Client/Assets/Scripts/XExtNativeInfo.cs67
1 files changed, 67 insertions, 0 deletions
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<AndroidJavaObject>("uniqueInstance");
+ density = jo.Call<int>("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<AndroidJavaObject>("uniqueInstance");
+ str = jo.Call<string>("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
+
+ }
+
+}