public void Awake() { // Make sure there are no other instances of this gameobject if (instance != null) { Destroy(gameObject); } else { instance = this; } }
public static HMSinglePlayerGameController instance; // HMGameController is a singleton. HMGameController.instance.DoSomeThing(); // Ensure that the instance is destroyed when the game is stopped in the editor. public void OnApplicationQuit() { instance = null; }