// Use this for initialization
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(this.gameObject);
     }
     player = GetComponent <AudioSource>();
     DontDestroyOnLoad(this.gameObject);
     player.PlayOneShot(musics.GetRandomClip());
 }
Example #2
0
 // Start is called before the first frame update
 void Start()
 {
     //Basically, we want the music player to presist through the program
     // but we don't want a new one to spawn every time we come back to the
     // Select screen
     //
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         GameObject.Destroy(this);
     }
 }