private void Start()
{
StartCoroutine(Waiting()); //开始协程
StopCoroutine(Waiting()); //结束协程
StopAllCoroutines(); //结束所有协程
}
IEnumerator Waiting()
{
yield return new WaitForSeconds(1f); //一秒后执行协程
...
}
?
?协程和DoTween
private Tweener tweener;
void Start()
{
tweener = transform.DOMove(Vector3.one, 1).SetLoops(5);
StartCoroutine(Wait());
}
private IEnumerator Wait()
{
yield return tweener.WaitForCompletion(); //动画完成之后执行下面的逻辑
yield return tweener.WaitForElapsedLoops(3); //三次循环之后执行下面的逻辑
yield return tweener.WaitForKill();
yield return tweener.WaitForPosition(1); //等待动画执行几秒之后
yield return tweener.WaitForRewind(); //动画重新执行
yield return tweener.WaitForStart();
}
|