private IEnumerator FadeOutCoroutine(float fadeTime = 1f) { while (source.volume > 0) { if (!isPaused) { source.volume -= Time.unscaledDeltaTime / fadeTime; } yield return(null); } Stop(); source.volume = 0.0001f; AudioEvents.AudioFadeOutEnd(); }
private IEnumerator FadeInCoroutine(float fadeTime = 1f, float MaxVolume = 1f) { Play(); source.volume = 0; while (source.volume < MaxVolume) { if (!isPaused) { source.volume += Time.unscaledDeltaTime / fadeTime; } if (!source.isPlaying) { Debug.Log("source " + source.isPlaying); Reset(); yield break; } yield return(null); } source.volume = MaxVolume; AudioEvents.AudioFadeInEnd(); }
public static void ReturnToPool(ExtendedAudioSource extendedAudioSource) { AudioEvents.AudioEndPlaying(extendedAudioSource); activeAudioSources.Remove(extendedAudioSource); extendedAudioSource.gameObject.SetActive(false); }