퐁듀블로그

블로그 이미지
by 초코맛퐁듀
  • Total hit
  • Today hit
  • Yesterday hit

예1) Do 함수를 실행하고 그것이 완료된 후에 코드 실행을 계속함

function Start() {

// 자바스크립트의 경우, yield Do(); 와 같음

// C#의 경우, 반드시 StartCoroutine 사용해야 함

yield StartCoroutine(Do());

Debug.Log("This is printed after 5 seconds");

Debug.Log("This is after the Do corutine has finished execution");

}

 

function Do() {

Debug.Log("Do now");

yield WaitForSeconds(5);

Debug.Log("Do 5 Seconds later");

}

 

* 결과는

(1) Do now

(2) Do 5 Seconds later

(3) This is printed 5 sends

(4) This is after the Do coroutine has finished execution

 

예2) function Start() {

Debug.Log("Starting = " + Time.time);

yield WaitAndPrint();

 

Debug.Log("Done WaitAndPrint = " + Time.time);

}

 

function WaitAndPrint() {

yield WaitFor Seconds(5);

Debug.Log("WaitAndPrint = " + Time.time);

}

 

* 결과는

(1) Startine = 0

(2) WaitAndPrint = 5.003615

(3) Done WaitAndPrint = 5.003615

 

 

1. WaitForFixedUpdate

- FixedUpdate 함수의 다음번 호출을 기다림

예) function Start() {

// FixedUpdate가 끝나길 기다림

yield new WaitForFixedUpdate();

// FixedUpdate 호출이 끝나면 이어서...

Debug.Log("Call after FixedUpdate");

}

 

function FixedUpdate() {

Debug.Log("FixedUpdate");

}

 

[출처] 유니티 주요함수 #3 | 작성자 만듀

'Unity3D' 카테고리의 다른 글

Unity 주요함수 #4  (0) 2014.01.16
Unity 주요함수 #2  (0) 2014.01.16
Unity 주요함수 #1  (0) 2014.01.16
AND

ARTICLE CATEGORY

이것저것 (6)
C# (0)
Unity3D (4)
리뷰 (1)

RECENT ARTICLE

RECENT COMMENT

CALENDAR

«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

ARCHIVE

LINK