I tried to use delegate chain like below, trying to make animation in unity:
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
}
I thought the Log will go like 1 (5 secs) 2 (5 secs) ... 10
but instead, 1 2 .. 10 was logged at the same time.
If I want to callback another Ie after 5 second, what should I do??