void Awake() { // Make this an indestructible singleton if (Instance == null) { Instance = this; } else if (!Instance.Equals(this)) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
/// <summary> /// Destroy this singleton instance /// </summary> public static void DestroySingleton() { Destroy(Instance.gameObject); Instance = null; }