WaitUntil은 항상 정말로 답장할 때 프레임을 기다립니까?

4409 단어 Unity

개요


코르크에 WaitUntil을 사용하면 진짜로 기다릴 거예요.
만약 항상 진짜로 되돌아온다면, yeld return null처럼 프레임을 기다립니까?

컨디션


Unity5.5.2p4

결실


대기 2

실험 내용


Unity 스크립트는 다음과 같습니다.
Supplied delegate will be executed each frame after script MonoBehaviour.Update and before MonoBehaviour.LateUpdate. When the delegate finally evaluates to true, the coroutine will proceed with its execution.
Update와 LateUpdate 사이에서 수행합니다.
이 기간 동안 출력 로그를 확인합니다.
using UnityEngine;
using System.Collections;

public class TestWaitUntil : MonoBehaviour
{
    private void Start()
    {
        StartCoroutine(Loop());
        StartCoroutine(Loop2());
    }

    private void Update()
    {
        Debug.Log("Update()");
    }

    private void LateUpdate()
    {
        Debug.Log("LateUpdate()");
    }

    IEnumerator Loop()
    {
        WaitUntil wait = new WaitUntil(() => { return true; });

        while(true)
        {
            Debug.Log("Loop() Start WaitUntil.");
            yield return wait;
            Debug.Log("Loop() End WaitUntil.");
        }
    }

    IEnumerator Loop2()
    {
        while(true)
        {
            Debug.Log("Loop2() Start.");
            yield return null;
            Debug.Log("Loop2() End.");
        }
    }
}

로그 출력

Loop() Start WaitUntil.
Loop2() Start.
Update()
LateUpdate()
Update()
Loop() End WaitUntil.
Loop() Start WaitUntil.
Loop2() End.
Loop2() Start.
LateUpdate()
Update()
Loop() End WaitUntil.
Loop() Start WaitUntil.
Loop2() End.
Loop2() Start.

후기


물론 시리즈.
일드문 있으니까 기다려.
안 그러면 무한순환이야.

좋은 웹페이지 즐겨찾기