/** * <summary>Gets, and creates if necessary, an AudioSource used for Narration speech. If the narratorSound variable is empty, one will be generated and its AudioSource referenced.</summary> * <returns>The AudioSource for Narration speech</returns> */ public AudioSource GetNarratorAudioSource() { if (narratorAudioSource == null) { if (narratorSound != null) { narratorAudioSource = narratorSound.GetComponent <AudioSource>(); } else { GameObject narratorSoundOb = new GameObject("Narrator"); UnityVersionHandler.PutInFolder(narratorSoundOb, "_Sounds"); narratorAudioSource = narratorSoundOb.AddComponent <AudioSource>(); AdvGame.AssignMixerGroup(narratorAudioSource, SoundType.Speech); narratorAudioSource.spatialBlend = 0f; narratorSound = narratorSoundOb.AddComponent <Sound>(); narratorSound.soundType = SoundType.Speech; } } narratorSound.SetMaxVolume(); return(narratorAudioSource); }
private void Awake() { if (surviveSceneChange) { if (transform.root != null && transform.root != gameObject.transform) { transform.SetParent(null); } DontDestroyOnLoad(this); } if (GetComponent <AudioSource>()) { audioSource = GetComponent <AudioSource>(); if (audioSource.playOnAwake) { isPlaying = true; audioSource.playOnAwake = false; } } audioSource.ignoreListenerPause = playWhilePaused; AdvGame.AssignMixerGroup(audioSource, soundType); }
/** * <summary>Gets, and creates if necessary, an AudioSource used for Narration speech.</summary> * <returns>The AudioSource for Narration speech</returns> */ public AudioSource GetNarratorAudioSource() { if (narratorAudioSource == null) { GameObject narratorSoundOb = new GameObject("Narrator"); UnityVersionHandler.PutInFolder(narratorSoundOb, "_Sounds"); narratorAudioSource = narratorSoundOb.AddComponent <AudioSource>(); AdvGame.AssignMixerGroup(narratorAudioSource, SoundType.Speech); #if UNITY_5 || UNITY_2017_1_OR_NEWER narratorAudioSource.spatialBlend = 0f; #endif Sound narratorSound = narratorSoundOb.AddComponent <Sound>(); narratorSound.soundType = SoundType.Speech; narratorSound.SetMaxVolume(); } return(narratorAudioSource); }
private void Awake() { if (surviveSceneChange) { DontDestroyOnLoad(this); } if (GetComponent <AudioSource>()) { audioSource = GetComponent <AudioSource>(); if (audioSource.playOnAwake) { isPlaying = true; audioSource.playOnAwake = false; } } audioSource.ignoreListenerPause = playWhilePaused; AdvGame.AssignMixerGroup(audioSource, soundType); }