void OnDestroy() { // Stopping all coroutines, even if this is not our original coroutine StopAllCoroutines(); if (this == _instance) { _instance = null; } }
void Awake() { if (_instance != null) { Debug.LogWarning("There is another instance of " + this + " already. Destroying the new one"); Destroy(this); return; } _instance = this; Scale = Time.timeScale; _instance.StartCoroutine(UpdateDeltaTime()); }