在播放动画完成之后,才能将物体销毁/进行操作/修改Time.timeScale。
碰到这样的需求,需要这样用到动画的回调函数:
public void LiveImagesFade()
{
Tweener tweener = liveImage.DOFade(1f, 0.5f);
tweener.OnComplete(LiveImageVanish);//调用回调函数OnComplete,参数是指向一个没有返回值和参数的函数的委托
}
void LiveImageVanish()
{
liveImage.DOFade(0.3f, 3f);
}
但是我还想给这个回调函数带参数怎么办?我希望这个面板渐隐之后,调用它的SetActive(false)方法,而我需要根据参数来判断此时是哪一个面板。
这里就要分析一下这个OnComplete函数的参数究竟是什么了:
//
// 摘要:
// Sets the onComplete callback for the tween. Called the moment the tween reaches
// its final forward position, loops included
public static T OnComplete<T>(this T t, TweenCallback action) where T : Tween;
//
// 摘要:
// Used for tween callbacks
public delegate void