Esempio n. 1
0
        public void PlayBackgroundMusic(AudioClip clip, AudioOptions audioOptions)
        {
            var audioSource = _backgroundMusicPooler.GetNextObject();

            audioSource.AudioSource.clip = clip;
            if (audioOptions.WithFade)
            {
                StartCoroutine(AudioFades.FadeIn(audioSource.AudioSource, audioOptions.FadeSpeed, audioOptions.Volume));
            }
            else
            {
                audioSource.AudioSource.volume = audioOptions.Volume;
                audioSource.AudioSource.Play();
            }
        }
Esempio n. 2
0
 public void StopAllBackgroundMusic(AudioOptions audioOptions)
 {
     foreach (var audioSourcePooleable in _backgroundMusicPooler.ActiveObjects)
     {
         if (audioOptions.WithFade)
         {
             StartCoroutine(AudioFades.FadeOut(audioSourcePooleable, audioOptions.FadeSpeed));
         }
         else
         {
             audioSourcePooleable.AudioSource.Stop();
             audioSourcePooleable.Deactivate();
         }
     }
 }
Esempio n. 3
0
        public void PlaySound(AudioClip clip, AudioOptions audioOptions)
        {
            audioOptions.LowPassFilter = _paused;
            var audioSource = audioOptions.LowPassFilter
                ? _lowPassFilterPooler.GetNextObject()
                : _audioClipPooler.GetNextObject();

            audioSource.SetClip(clip);
            audioSource.StartClip();
            if (audioOptions.WithFade)
            {
                StartCoroutine(AudioFades.FadeIn(audioSource.AudioSource, audioOptions.FadeSpeed, audioOptions.Volume));
            }
            else
            {
                audioSource.SetVolume(audioOptions.Volume);
            }
        }