Example #1
0
 // Use this for initialization
 void Awake()
 {
     if (SoundManagerScript.CheckInstanceExist())
     {
         Destroy(this.gameObject);
     }
 }
Example #2
0
    // Preload before any Start() rins in other scripts
    void Awake()
    {
        if (SoundManagerScript.CheckInstanceExist())
        {
            Destroy(this.gameObject);
        }

        AudioSource[] audioSourceList = this.GetComponentsInChildren <AudioSource> ();

        if (audioSourceList [0].gameObject.name == "BGMAudioSource")
        {
            bgmAudioSource = audioSourceList [0];
            sfxAudioSource = audioSourceList [1];
        }
        else
        {
            bgmAudioSource = audioSourceList [1];
            sfxAudioSource = audioSourceList [0];
        }
    }