Exemple #1
0
        /// <summary>
        /// 恢复播放背景音乐
        /// </summary>
        /// <param name="isGradual">是否渐进式</param>
        public void ResumeBackgroundMusic(bool isGradual = true)
        {
            BackgroundSource.DOKill();

            if (isGradual)
            {
                BackgroundSource.volume = 0;
                BackgroundSource.UnPause();
                BackgroundSource.DOFade(BackgroundVolume, 2);
            }
            else
            {
                BackgroundSource.UnPause();
                BackgroundSource.volume = BackgroundVolume;
            }
        }
Exemple #2
0
        /// <summary>
        /// 暂停播放背景音乐
        /// </summary>
        /// <param name="isGradual">是否渐进式</param>
        public void PauseBackgroundMusic(bool isGradual = true)
        {
            BackgroundSource.DOKill();

            if (isGradual)
            {
                BackgroundSource.DOFade(0, 2).OnComplete(() =>
                {
                    BackgroundSource.Pause();
                    BackgroundSource.volume = BackgroundVolume;
                });
            }
            else
            {
                BackgroundSource.Pause();
                BackgroundSource.volume = BackgroundVolume;
            }
        }
        /// <summary>
        /// 恢复播放背景音乐
        /// </summary>
        /// <param name="isGradual">是否渐进式</param>
        public void UnPauseBackgroundMusic(bool isGradual = true)
        {
            if (_bgPauseTweener != null)
            {
                _bgPauseTweener.Kill();
                _bgPauseTweener = null;
            }

            if (isGradual)
            {
                BackgroundSource.volume = 0;
                BackgroundSource.UnPause();
                _bgPauseTweener = BackgroundSource.DOFade(BackgroundVolume, 2).OnComplete(() =>
                {
                    _bgPauseTweener = null;
                });
            }
            else
            {
                BackgroundSource.UnPause();
                BackgroundSource.volume = BackgroundVolume;
            }
        }