示例#1
0
 public void Start()                                                 // Destroys this in case another instance is present
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
示例#2
0
    public static PB_Controller instance;               // PB_Controller is a singleton. PB_Controller.instance.DoSomeThing();

    public void OnApplicationQuit()                     // Ensure that the instance is destroyed when the game is stopped in the editor.
    {
        instance = null;
    }