/// <summary> /// Only sets the value /// </summary> void game_setSound() { //finding Audio source once EasyAudioUtility am = FindObjectOfType <EasyAudioUtility>(); for (int i = 0; i < am.helper.Length; i++) { //define all the sounds present in the Easy Audio Utility if (am.helper[i].name == "Hover") { soundSource[i] = am.helper[i]; } if (am.helper[i].name == "Click") { soundSource[i] = am.helper[i]; } } foreach (EasyAudioUtility_Helper s in soundSource) { s.volume = soundValue; sound_slider.value = soundValue; } }
/// <summary> /// Only sets the value /// </summary> void game_setMusic() { //finding correct Audio Source EasyAudioUtility am = FindObjectOfType <EasyAudioUtility>(); for (int i = 0; i < am.helper.Length; i++) { if (am.helper[i].name == "BG") { musicSource = am.helper[i].source; if (!musicSource.isPlaying) { musicSource.Play(); } } } musicSource.volume = musicValue; music_slider.value = musicValue; }
void Awake() { //creating static instance so we don't need any physical reference if (instance != null) { Destroy(gameObject); } else { instance = this; DontDestroyOnLoad(gameObject); } //Adding audio source in all helpers foreach (EasyAudioUtility_Helper h in helper) { h.source = gameObject.AddComponent <AudioSource>(); h.source.clip = h.clip; h.source.loop = h.loop; h.source.outputAudioMixerGroup = mixerGroup; } //playing BG Audio Clip on Main Menu if (FindObjectOfType <MainMenuController>()) { Play("BG"); if (FindObjectOfType <OptionsController_Game>()) { foreach (EasyAudioUtility_Helper h in helper) { if (h.name == "BG") { FindObjectOfType <OptionsController_Game>().musicSource = h.source; } } } } }
void Awake() { //creating static instance so we don't need any physical reference if (Instance != null) { Destroy(gameObject); } else { Instance = this; DontDestroyOnLoad(gameObject); } //Adding audio source in all helpers foreach (EasyAudioUtility_Helper h in helper) { h.source = gameObject.AddComponent <AudioSource>(); h.source.clip = h.clip; h.source.loop = h.loop; h.source.outputAudioMixerGroup = mixerGroup; } Play(Som.Background); }