发现了用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;
}
}
);
}