Unity3D笔记----CustomYieldInstruction

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

你可能感兴趣的:(Unity3D笔记----CustomYieldInstruction)