public virtual void PauseMusic() { if (CurrentMusicAudioSource != null) { CurrentMusicAudioSource.Pause(); } }
public void FadeMusic(float volume, float duration) { // currentMusicAudioSource may be null if (CurrentMusicAudioSource == null) { return; } if (_muteMusic) { CurrentMusicAudioSource.Pause(); return; } if (!CurrentMusicAudioSource.isPlaying) { CurrentMusicAudioSource.Play(); } if (_musicFadeOutTweener != null) { _musicFadeOutTweener.Kill(); } if (duration <= 0) { CurrentMusicAudioSource.volume = volume; if (volume < .1f) { CurrentMusicAudioSource.Pause(); } } else { _musicFadeOutTweener = DOTween.To(() => CurrentMusicAudioSource.volume, (val) => CurrentMusicAudioSource.volume = val, volume, duration).OnComplete(() => this.DoneMusicFade(CurrentMusicAudioSource)); } }