DOTween充当计时器的小技巧

发现了用dotween充当定时器的小技巧,非常实用

        public void SetSoundVolumeByTime(float startvalue,float endvalue,float time)
        {
            inSetSoundVolumeByTime = true;
            audioMusicSource.volume = startvalue;
            DOTween.To(() => audioMusicSource.volume, x => audioMusicSource.volume = x, endvalue, time).OnComplete
             (
                () =>
                {
                    if (startvalue == 1)
                    {
                    }
                    else
                    {
                        inSetSoundVolumeByTime = false;
                    }
                }
             );
        }

你可能感兴趣的:(Unity)