Esempio n. 1
0
    public static PB_GameController instance;                   // PB_GameController is a singleton. PB_GameController.instance.DoSomeThing();


    public void OnApplicationQuit()                                                     // Ensure that the instance is destroyed when the game is stopped in the editor.
    {
        PlayerPrefs.SetInt("TotalScore", _totalScore);
        PlayerPrefs.SetInt("HighScore", _highScore);
        PlayerPrefs.SetInt("UpdateHiScore", _updateHighScoreCnt);
        PlayerPrefs.Save();

        instance = null;
    }
 void Awake()
 {       // Singleton: Destroys itself in case another instance is already in the scene
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Esempio n. 3
0
 public void Awake()                 // Singleton: Destroys itself in case another instance is already in the scene
 //PlayerPrefs.DeleteAll();
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
    public static PB_GameController instance;           // PB_GameController is a singleton. PB_GameController.instance.DoSomeThing();


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