Example #1
0
 public void Awake()                             // Make sure there are no other instances of this gameobject
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
     }
 }
Example #2
0
 public static HMGameController 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;
 }