Example #1
0
 private void Start()
 {
     if (pauseOtherBackgroundMusic)
     {
         AudioManager.Instance.StopAllBackgroundMusic(AudioOptions.Default());
     }
     AudioManager.Instance.PlayBackgroundMusic(audioClip.audioClip, new AudioOptions {
         Volume = audioClip.volume
     });
 }
Example #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();
         }
     }
 }
Example #3
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();
            }
        }
Example #4
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);
            }
        }
Example #5
0
 public void PlaySound(AudioClip clip)
 {
     PlaySound(clip, AudioOptions.Default());
 }