【发布时间】:2018-12-25 23:08:10
【问题描述】:
我尝试使用如下委托链,尝试统一制作动画:
public class Class1
{
class Dele {
delegate void MyDelegate();
private MyDelegate dele;
private int count = 0;
public void Animate() {
dele = new MyDelegate(DoIe);
}
IEnumerator Ie() {
Debug.Log(count);
count += 1;
yield return new WaitForSeconds(5f);
}
private void DoIe() {
StartCouroutine(Ie());
for (int i=0; i<10; i++) {
dele += DoIe;
}
dele();
}
}
//call new Dele().Animate() here
}
我认为日志会像 1 (5 秒) 2 (5 秒) ... 10
但是, 1 2 .. 10 被同时记录。
如果我想在 5 秒后回调另一个 Ie, 我该怎么办??
【问题讨论】:
标签: c# unity3d callback delegates