void OnDestroy() { if (ReferenceEquals(this, instance)) { instance = null; } #if UNITY_5_4_OR_NEWER SceneManager.sceneLoaded -= sceneLoadedHandler; #endif }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(this); return; } #if TOUCHSCRIPT_DEBUG pLogger = Debugging.TouchScriptDebugger.Instance.PointerLogger; #endif #if UNITY_5_4_OR_NEWER SceneManager.sceneLoaded += sceneLoadedHandler; #endif gameObject.hideFlags = HideFlags.HideInHierarchy; DontDestroyOnLoad(gameObject); layerManager = LayerManager.Instance; UpdateResolution(); StopAllCoroutines(); StartCoroutine(lateAwake()); pointerListPool.WarmUp(2); intListPool.WarmUp(3); _layerAddPointer = layerAddPointer; _layerUpdatePointer = layerUpdatePointer; _layerRemovePointer = layerRemovePointer; _layerCancelPointer = layerCancelPointer; #if UNITY_5_6_OR_NEWER samplerUpdateInputs = CustomSampler.Create("[TouchScript] Update Inputs"); samplerUpdateAdded = CustomSampler.Create("[TouchScript] Added Pointers"); samplerUpdatePressed = CustomSampler.Create("[TouchScript] Press Pointers"); samplerUpdateUpdated = CustomSampler.Create("[TouchScript] Update Pointers"); samplerUpdateReleased = CustomSampler.Create("[TouchScript] Release Pointers"); samplerUpdateRemoved = CustomSampler.Create("[TouchScript] Remove Pointers"); samplerUpdateCancelled = CustomSampler.Create("[TouchScript] Cancel Pointers"); #endif }