반응형
중첩 코루틴
코루틴 내부에서 또다른 코루틴을 호출한다. 해당 코루틴이 완료될 때까지 기다리게 된다. 의존성이 있는 여러 작업을 수행하는데 유리하게 사용 될 수 있다.
void Start () {
StartCoroutine (TestRoutine());
}
IEnumerator TestRoutine() {
Debug.Log ("Run TestRoutine");
yield return StartCoroutine (OtherRoutine ());
Debug.Log ("Finish TestRoutine");
}
IEnumerator OtherRoutine() {
Debug.Log ("Run OtherRoutine #1");
yield return new WaitForSeconds (1.0f);
Debug.Log ("Run OtherRoutine #2");
yield return new WaitForSeconds (1.0f);
Debug.Log ("Run OtherRoutine #3");
yield return new WaitForSeconds (1.0f);
Debug.Log ("Finish OtherRoutine");
}
반응형
'unity C#' 카테고리의 다른 글
[Unity] float 반올림, 올림, 내림 (0) | 2023.01.30 |
---|---|
[Unity] 화면보호기 끄기 (0) | 2023.01.30 |
[Unity] UI Blur Shader (0) | 2023.01.05 |
[Unity] VS Code Settings Sync (0) | 2022.12.26 |
[Unity] 암호화 복호화 (0) | 2022.11.29 |