private void Start() { GameObject gameObject = GameObject.FindGameObjectWithTag("Sound & Music"); if (gameObject) { audioSource_ = gameObject.GetComponent<SoundAndMusic>(); } else { audioSource_ = Instantiate(soundAndMusic_).GetComponent<SoundAndMusic>(); } }
/// <summary> /// /////////////////////////// = Initializations = ///////////////////////////////////// /// </summary> void Awake() { if (_instance == null) { _instance = this; DontDestroyOnLoad(this.gameObject); } else { Destroy(gameObject); } }
//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); }