public class WaitForComplete : CustomYieldInstruction
{
public bool Complete = false;
public override bool keepWaiting
{
get
{
return !Complete;
}
}
}
public IEnumerator DoSomething()
{
var waitForComplete = new WaitForComplete();
func(waitForComplete);
yield return waitForComplete;
}
这个示例展示了自定义协程的用法,DoSomething会被挂起,直到keepWaiting==false
网友评论