protected void Awake() { // Check if we already have a scene manager if (m_Instance != null) { if (Application.isPlaying) { Destroy(this); } else { DestroyImmediate(this); } Debug.LogWarning("Multiple UISceneManagers are not allowed, destroying."); return; } // Save reference in the static variable m_Instance = this; // Prepare the list if (this.m_Scenes == null) { this.m_Scenes = new List <UIScene>(); } // Prevent destruction on scene load if (Application.isPlaying) { DontDestroyOnLoad(this.gameObject); } }
protected void OnDestroy() { // Remove reference m_Instance = null; }