Coroutine

ㅋㅋ·2022년 6월 29일

유니티

목록 보기
3/6

코루틴 함수 실행

StartCoroutine(FunctionName(Parameter));

코루틴 함수 특징

IEnumerator FunctionName(Vector3 Parameter)
{
	yield return (Null or Condition);
    
    ...
    
}

IEnumerator를 반환하도록 구현해야 함

yield 시 함수 실행을 멈추고,

조건을 만족하거나 다음 프레임에 yield 다음 구문부터 실행하게 됨


조건들

  • WaitForSeconds(float Seconds)
    게임 내의 시간으로 해당 초 이후 실행
  • WaitForSecondsRealtime(float Seconds)
    현실 시간으로 해당 초 이후 실행

  • WaitForEndOfFrame()
    한 프레임이 끝난 이후 실행
    카메라와 UI가 렌더링되고, 그것들이 화면에 표시되기 전

  • WaitForFixedUpdate()
    FixedUpdate가 되기 전까지 기다리고, FixedUpdate 때 실행

  • WaitUntil(Delegate evaluate)
    Until 함수는 조건이 false인 동안 기다리고, true가 될 때 다음 구문 실행

  • WaitWhile(Delegate evaluate)

    While 함수는 조건이 true인 동안 기다리고, false가 될 때 다음 구문 실행

0개의 댓글