示例#1
0
        IEnumerator ICrossFade(LevelAudioSettings las)
        {
            crossfading      = true;
            inactiveBGM.clip = las.clip;
            inactiveBGM.Play();
            inactiveBGM.pitch = las.pitch;

            while (activeBGM.volume > cutoffThreshold && las.fadeRate > 0)
            {
                activeBGM.volume   -= las.fadeRate;
                inactiveBGM.volume += las.fadeRate;

                yield return(null);
            }

            inactiveBGM.volume = 1;
            activeBGM.volume   = 0;
            activeBGM.Stop();
            AudioSource temp = activeBGM;

            activeBGM   = inactiveBGM;
            inactiveBGM = temp;

            crossfading = false;
        }
示例#2
0
        public void CrossFade(LevelAudioSettings las)
        {
            if (crossfading)
            {
                return;
            }

            StartCoroutine(ICrossFade(las));
        }