private void OnDestroy() { #if UNITY_EDITOR if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode) #endif { if (_instance == this) { Logger.LogWarning("PromiseBehaviour destroyed! Promise callbacks will no longer be automatically invoked!"); _instance = null; } } }
private void Start() { if (_instance != null) { Logger.LogWarning("There can only be one instance of PromiseBehaviour. Destroying new instance."); Destroy(this); return; } DontDestroyOnLoad(gameObject); gameObject.hideFlags = HideFlags.HideAndDontSave; // Don't show in hierarchy and don't destroy. _instance = this; StartCoroutine(_Enumerator()); }