美文网首页
Unity3D笔记----CustomYieldInstruct

Unity3D笔记----CustomYieldInstruct

作者: hepingle | 来源:发表于2020-09-30 14:03 被阅读0次

    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笔记----CustomYieldInstruct

          本文链接:https://www.haomeiwen.com/subject/mhbuuktx.html