private void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
void playMusic() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
// Use this for initialization void Start() { if (musicMenu == null) { //if not, set instance to this musicMenu = this; //If instance already exists and it's not this: } else if (musicMenu != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } if (GameObject.Find("gameMusic")) { Destroy(GameObject.Find("gameMusic")); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); sounds = GetComponents <AudioSource>(); music = sounds[0]; //if (!AudioBegin) //{ music.Play(); DontDestroyOnLoad(gameObject); // AudioBegin = true; //} }