private void Awake() { manager = GameObject.Find("ManagerObj").GetComponent <SingletonAudio>(); inspirationState = new InspirationState(this); composingState = new ComposingState(this); stopState = new StopState(this); }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
void Awake() { if (_instance == null) { //make the first instance a singleton _instance = this; DontDestroyOnLoad(this); } else { //if singleton already exists find reference and destroy if (this != _instance) { Destroy(this.gameObject); } } }
void Awake() { if (instance != null && instance != this) { if (instance.GetComponent <AudioSource>().clip != GetComponent <AudioSource>().clip) { instance.GetComponent <AudioSource>().clip = GetComponent <AudioSource>().clip; instance.GetComponent <AudioSource>().volume = GetComponent <AudioSource>().volume; instance.GetComponent <AudioSource>().Play(); } Destroy(this.gameObject); return; } instance = this; GetComponent <AudioSource>().Play(); DontDestroyOnLoad(this.gameObject); }