public void WillUnload() { AudioSource[] sources = GetComponentsInChildren <AudioSource>(); foreach (AudioSource source in sources) { if (source.isPlaying) { StartCoroutine(AudioHelper.FadeOutOverSeconds(source, ViewLoader.AudioFadeoutTime)); } } }
public bool SetVOState(bool enabled) { VOEnabled = enabled; if (VOEnabled) { audioSource.volume = defaultVolume; } else { clipQueue.Clear(); StartCoroutine(AudioHelper.FadeOutOverSeconds(audioSource, FadeOutTime)); } return(VOEnabled); }
public void Stop(bool clearQueue = false) { if (clearQueue) { clipQueue.Clear(); } nextClip = null; // Fade out the audio that's currently playing to stop it. Check here to // prevent coroutines from stacking up and calling Stop() on audioSource // at undesired times. Audio that would be faded out instead would just // be skipped over if the queue was cleared, which is what we want. if (!AudioHelper.FadingOut) { StartCoroutine(AudioHelper.FadeOutOverSeconds(audioSource, FadeOutTime)); } }