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