private void Awake() { if (this._destroyed) { return; } UpsightManager[] objectsOfType = (UpsightManager[])Object.FindObjectsOfType <UpsightManager>(); bool flag = false; if (objectsOfType.Length > 1) { foreach (UpsightManager upsightManager in objectsOfType) { if (((Object)((Component)upsightManager).get_gameObject()).get_name() == nameof(UpsightManager) && !flag) { flag = true; } else if (!upsightManager._destroyed) { upsightManager._destroyed = true; Object.Destroy((Object)upsightManager); } } } if (!flag) { UpsightManager.init(); } else { UpsightManager.initialized = true; } }
public static void init() { if (Application.get_platform() != 11) { return; } try { using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.upsight.android.unity.UpsightPlugin")) { if (((AndroidJavaObject)androidJavaClass).CallStatic <bool>("isEnabled", new object[0]) == null) { Debug.LogWarning((object)"Upsight.init() was called but the SDK is currently disabled from the Upsight SDK Management Extension. Upsight will not initialize."); return; } } } catch { Debug.LogError((object)"Error while checking if the Upsight SDK is enabled. Unable to initialize"); return; } if (Upsight.Initialized) { return; } Upsight.Initialized = true; UpsightManager.init(); try { Upsight._pluginBase = new AndroidJavaObject("com.upsight.android.unity.UpsightPlugin", new object[0]); if (Upsight._pluginBase != null) { if (!(AndroidJNI.ExceptionOccurred() != IntPtr.Zero)) { goto label_15; } } Debug.LogError((object)"Upsight initialization failed! JNI Exception thrown:"); AndroidJNI.ExceptionDescribe(); Upsight._pluginBase = (AndroidJavaObject)null; AndroidJNI.ExceptionClear(); return; } catch (Exception ex) { Debug.LogError((object)"Upsight initialization failed!"); Debug.LogException(ex); Upsight._pluginBase = (AndroidJavaObject)null; return; } label_15: try { Upsight._pluginMarketingExtension = new AndroidJavaObject("com.upsight.android.unity.UpsightMarketingManager", new object[0]); if (Upsight._pluginMarketingExtension != null) { Upsight._pluginBase.Call("registerExtension", new object[1] { (object)Upsight._pluginMarketingExtension }); } } catch { Debug.LogWarning((object)"Upsight Marketing Extension not included."); Upsight._pluginMarketingExtension = (AndroidJavaObject)null; } try { Upsight._pluginPushExtension = new AndroidJavaObject("com.upsight.android.unity.UpsightPushManager", new object[0]); if (Upsight._pluginPushExtension == null) { return; } Upsight._pluginBase.Call("registerExtension", new object[1] { (object)Upsight._pluginPushExtension }); } catch { Debug.LogWarning((object)"Upsight Push Extension not included."); Upsight._pluginPushExtension = (AndroidJavaObject)null; } }