| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  | using System.Runtime.CompilerServices; | 
					
						
							|  |  |  | using UnityEngine; | 
					
						
							|  |  |  | using System; | 
					
						
							|  |  |  | using System.Runtime.InteropServices; | 
					
						
							|  |  |  | using AOT; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public static class NativeTool | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     private static Action<bool> mShareResultDel; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public static void Shake(int pType, float pIntensity)//0 light,1 medium,2 heavy | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  | #if UNITY_EDITOR | 
					
						
							|  |  |  |         //Debug.Log($"Shake {pType} with intensity {pIntensity}"); | 
					
						
							|  |  |  | #elif UNITY_IOS | 
					
						
							|  |  |  |         mShake(pType, pIntensity); | 
					
						
							|  |  |  | #elif UNITY_ANDROID | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |         TKGSDKManager.Instance.Shake(pType, pIntensity); | 
					
						
							|  |  |  |         //mShake(pType * pType * 20 + (int)(pIntensity * (pType + 1) * 10)); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  | #endif | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-09 14:35:49 +00:00
										 |  |  |     public static void Share(string pContent, Action<bool> pResultDel = null) | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         mShareResultDel = pResultDel; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if UNITY_EDITOR | 
					
						
							|  |  |  |         mShareResultDel?.Invoke(true); | 
					
						
							|  |  |  | #elif UNITY_IOS | 
					
						
							| 
									
										
										
										
											2022-09-09 14:35:49 +00:00
										 |  |  |         mShare(pContent, "", onShareCallback); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  | #elif UNITY_ANDROID | 
					
						
							| 
									
										
										
										
											2022-09-09 14:35:49 +00:00
										 |  |  |         TKGSDKManager.Instance.Share(pContent); | 
					
						
							|  |  |  |         //mShare(pContent); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  | #endif | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if UNITY_IOS | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [DllImport("__Internal")] | 
					
						
							|  |  |  |     private static extern void mShake(int pType, float pIntensity); | 
					
						
							|  |  |  |     [DllImport("__Internal")] | 
					
						
							|  |  |  |     private static extern void mShare(string pTitle, string pUrl, BoolResultDelegate pResultCallback); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     internal delegate void BoolResultDelegate(bool pResult); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [MonoPInvokeCallback(typeof(BoolResultDelegate))] | 
					
						
							|  |  |  |     private static void onShareCallback(bool pResult) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         mShareResultDel?.Invoke(pResult); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if UNITY_ANDROID | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |     //private static AndroidJavaClass javaObj = new AndroidJavaClass("com.toukagames.NativeTool"); | 
					
						
							|  |  |  |     //private static AndroidJavaObject mInstance = null; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |     //private static void mShake(long mMilliSeconds) | 
					
						
							|  |  |  |     //{ | 
					
						
							|  |  |  |     //    if (mInstance == null) | 
					
						
							|  |  |  |     //        mInstance = javaObj.CallStatic<AndroidJavaObject>("GetInstance"); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |     //    mInstance.Call("Shake", mMilliSeconds); | 
					
						
							|  |  |  |     //} | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-09 14:35:49 +00:00
										 |  |  |     //private static void mShare(string pTitle) | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |     //{ | 
					
						
							|  |  |  |     //    if (mInstance == null) | 
					
						
							|  |  |  |     //        mInstance = javaObj.CallStatic<AndroidJavaObject>("GetInstance"); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-09 14:35:49 +00:00
										 |  |  |     //    mInstance.Call("Share", pTitle); | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |     //    mShareResultDel?.Invoke(true); | 
					
						
							|  |  |  |     //} | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  | #endif | 
					
						
							|  |  |  | } |