Exemple #1
0
        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();
        }
Exemple #2
0
        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();
        }
Exemple #3
0
 public static void ReturnToPool(ExtendedAudioSource extendedAudioSource)
 {
     AudioEvents.AudioEndPlaying(extendedAudioSource);
     activeAudioSources.Remove(extendedAudioSource);
     extendedAudioSource.gameObject.SetActive(false);
 }