private void OnTriggerEnter2D(Collider2D collision) { PersistentAudio audio = GameObject.FindGameObjectWithTag("Persistent").GetComponent <PersistentAudio>(); if (audio.isPlaying != toPlay) { audio.ChangeMusic(toPlay); } }
public void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }