Example #1
0
 public void Awake()                                                 // Singleton: Destroys itself in case another instance is already in the scene
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
     }
 }
 void Start()
 {
     SoundController.instance.Play(_startSound, .75f, 1.0f);
     _title.SetActive(true);                                 // Enable start screen
     _titleContainer.SetActive(true);                        // Enable title screen
     _startText.SetActive(true);                             // Enable start text
     // _highScore = PlayerPrefs.GetInt("HighScore");           // Load save data: Highscore
     SetHighScoreText();                                     // Set UI text for highscore
     SetScore();                                             // Set UI text
     _player = PB_Player.instance;                           // Reference to player singleton
     CheckUnlocks();                                         // Check what characters are unlocked based on score
 }
Example #3
0
    public static PB_Player instance;                           // Singleton: PB_Player is a singleton. PB_Player.instance.DoSomeThing();


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