Unity/스크립트
코루틴 문제
빨강꼬마
2018. 6. 21. 18:48
코루틴을 이해하고 있는지 알아보는 문제.
만들었던 나조차 한번 틀렸다-_-...
아래와 같은 코드가 있다고 가정하고
콘솔에 찍히는 숫자를 순서대로 나열하면? (당연히 머리로만 계산해서+_+)
using System.Collections;
using UnityEngine;
public class Test: MonoBehaviour
{
private void Start()
{
StartCoroutine(Test1());
}
IEnumerator Test1()
{
Debug.Log("1");
IEnumerator enumerator = A();
Debug.Log("2");
while (enumerator.MoveNext())
{
Debug.Log("3");
yield return null;
Debug.Log("4");
}
Debug.Log("5");
}
IEnumerator A()
{
Debug.Log("6");
yield return false;
Debug.Log("7");
yield break;
Debug.Log("8");
}
}