Beispiel #1
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
         SceneManager.sceneLoaded += OnSceneLoaded;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Beispiel #2
0
    // Singleton
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Beispiel #3
0
 // Start is called before the first frame update
 void Awake() //Awake is called right before start
 {
     if (isPlaying == null)
     {
         DontDestroyOnLoad(transform.gameObject);
         isPlaying = this;
     }
     else if (isPlaying != this)
     {
         Destroy(transform.gameObject);
     }
     if (PlayerPrefs.HasKey("MusicVolume"))
     {
         musicVolume      = PlayerPrefs.GetFloat("MusicVolume");
         mainTheme.volume = musicVolume;
     }
     else
     {
         musicVolume      = 0.2f;
         mainTheme.volume = musicVolume;
     }
 }