void Awake(){ if(instance == null){ //making sure we only initialize one instance. instance = this; GameObject.DontDestroyOnLoad(this.gameObject); } else { //Destroying unused instances. GameObject.Destroy(this.gameObject); } }
// private static AndroidJavaObject jniUnityEventHandler = null; #endif public static void Initialize(IStoreAssets storeAssets) { if (string.IsNullOrEmpty(Soomla.GetInstance().customSecret) || string.IsNullOrEmpty(Soomla.GetInstance().soomSec)) { StoreUtils.LogError(TAG, "SOOMLA/UNITY MISSING customSecret or soomSec !!! Stopping here !!"); throw new ExitGUIException(); } if (Soomla.GetInstance().customSecret == Soomla.ONLY_ONCE_DEFAULT || Soomla.GetInstance().soomSec == Soomla.ONLY_ONCE_DEFAULT) { StoreUtils.LogError(TAG, "SOOMLA/UNITY You have to change customSecret and soomSec !!! Stopping here !!"); throw new ExitGUIException(); } //init SOOM_SEC #if UNITY_ANDROID && !UNITY_EDITOR if (string.IsNullOrEmpty(Soomla.GetInstance().androidPublicKey)) { StoreUtils.LogError(TAG, "SOOMLA/UNITY MISSING publickKey !!! Stopping here !!"); throw new ExitGUIException(); } if (Soomla.GetInstance().androidPublicKey == Soomla.AND_PUB_KEY_DEFAULT) { StoreUtils.LogError(TAG, "SOOMLA/UNITY You have to change android publicKey !!! Stopping here !!"); throw new ExitGUIException(); } AndroidJNI.PushLocalFrame(100); using (AndroidJavaClass jniStoreAssets = new AndroidJavaClass("com.soomla.unity.StoreAssets")) { jniStoreAssets.CallStatic("setSoomSec", Soomla.GetInstance().soomSec); } AndroidJNI.PopLocalFrame(IntPtr.Zero); #elif UNITY_IOS && !UNITY_EDITOR storeController_SetSSV(Soomla.GetInstance().iosServerSideVerification); storeController_SetSoomSec(Soomla.GetInstance().soomSec); #endif StoreInfo.Initialize(storeAssets); #if UNITY_ANDROID && !UNITY_EDITOR AndroidJNI.PushLocalFrame(100); //init EventHandler using (AndroidJavaClass jniEventHandler = new AndroidJavaClass("com.soomla.unity.EventHandler")) { jniEventHandler.CallStatic("initialize"); } using (AndroidJavaObject jniStoreAssetsInstance = new AndroidJavaObject("com.soomla.unity.StoreAssets")) { using (AndroidJavaClass jniStoreControllerClass = new AndroidJavaClass("com.soomla.store.StoreController")) { jniStoreController = jniStoreControllerClass.CallStatic <AndroidJavaObject>("getInstance"); jniStoreController.Call("initialize", jniStoreAssetsInstance, Soomla.GetInstance().androidPublicKey, Soomla.GetInstance().customSecret); } } AndroidJNI.PopLocalFrame(IntPtr.Zero); // setting test mode on Android SetAndroidTestMode(Soomla.GetInstance().androidTestMode); #elif UNITY_IOS && !UNITY_EDITOR storeController_Init(Soomla.GetInstance().customSecret); #endif }
void Awake() { if (instance == null) //making sure we only initialize one instance. { instance = this; GameObject.DontDestroyOnLoad(this.gameObject); } else //Destroying unused instances. { GameObject.Destroy(this.gameObject); } }
// private static AndroidJavaObject jniUnityEventHandler = null; #endif public static void Initialize(IStoreAssets storeAssets) { if (string.IsNullOrEmpty(Soomla.GetInstance().customSecret) || string.IsNullOrEmpty(Soomla.GetInstance().soomSec)) { StoreUtils.LogError(TAG, "SOOMLA/UNITY MISSING customSecret or soomSec !!! Stopping here !!"); throw new ExitGUIException(); } if (Soomla.GetInstance().customSecret == Soomla.ONLY_ONCE_DEFAULT || Soomla.GetInstance().soomSec == Soomla.ONLY_ONCE_DEFAULT) { StoreUtils.LogError(TAG, "SOOMLA/UNITY You have to change customSecret and soomSec !!! Stopping here !!"); throw new ExitGUIException(); } //init SOOM_SEC #if UNITY_ANDROID if (string.IsNullOrEmpty(Soomla.GetInstance().androidPublicKey)) { StoreUtils.LogError(TAG, "SOOMLA/UNITY MISSING publickKey !!! Stopping here !!"); throw new ExitGUIException(); } if (Soomla.GetInstance().androidPublicKey == Soomla.AND_PUB_KEY_DEFAULT) { StoreUtils.LogError(TAG, "SOOMLA/UNITY You have to change android publicKey !!! Stopping here !!"); throw new ExitGUIException(); } AndroidJNI.PushLocalFrame(100); using (AndroidJavaClass jniStoreAssets = new AndroidJavaClass("com.soomla.unity.StoreAssets")) { jniStoreAssets.CallStatic("setSoomSec", Soomla.GetInstance().soomSec); } AndroidJNI.PopLocalFrame(IntPtr.Zero); #elif UNITY_IOS storeController_SetSoomSec(Soomla.GetInstance().soomSec); #endif StoreInfo.Initialize(storeAssets); #if UNITY_ANDROID AndroidJNI.PushLocalFrame(100); using (AndroidJavaObject jniStoreAssetsInstance = new AndroidJavaObject("com.soomla.unity.StoreAssets")) { using (AndroidJavaClass jniStoreControllerClass = new AndroidJavaClass("com.soomla.store.StoreController")) { jniStoreController = jniStoreControllerClass.CallStatic <AndroidJavaObject>("getInstance"); jniStoreController.Call("initialize", jniStoreAssetsInstance, Soomla.GetInstance().androidPublicKey, Soomla.GetInstance().customSecret); } } //init EventHandler using (AndroidJavaClass jniEventHandler = new AndroidJavaClass("com.soomla.unity.EventHandler")) { jniEventHandler.CallStatic("initialize"); } AndroidJNI.PopLocalFrame(IntPtr.Zero); // setting test mode on Android SetAndroidTestMode(Soomla.GetInstance().androidTestMode); #elif UNITY_IOS storeController_Init(Soomla.GetInstance().customSecret); #endif #if UNITY_EDITOR if (UnityEngine.Random.value < 0.1) { // make billing ddisabled StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Simulate disabled billing"); Events.OnBillingNotSupported(); } else { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Simulate enabled billing"); Events.OnBillingSupported(); } #endif }