private void Start()
    {
        GameObject gameObject = GameObject.FindGameObjectWithTag("Sound & Music");

        if (gameObject) {
            audioSource_ = gameObject.GetComponent<SoundAndMusic>();
        } else {
            audioSource_ = Instantiate(soundAndMusic_).GetComponent<SoundAndMusic>();
        }
    }
Esempio n. 2
0
 /// <summary>
 /// /////////////////////////// = Initializations = /////////////////////////////////////
 /// </summary>
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Esempio n. 3
0
    //public int PickMus; //Number in music array.
    //public int PickSfx; //Number in Sfx array.

    void Awake()
    {
        Music = Resources.LoadAll<AudioClip>("Audio/Music");
        SoundEffects = Resources.LoadAll<AudioClip>("Audio/SoundEffects");

        if (instance == null)
        {
            instance = this;
        }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }