|
|
°ÔÀÓ Äڵ带 ¾µ ¶§, Çϳª´Â À̺¥Æ®ÀÇ ¼ø¼¸¦ ½ºÅ©¸³Æ®¸¦ ÇÊ¿äÇØ ÇÏ¸é ³¡³»¾ßÇÑ´Ù. ÀÌ°ÍÀº ´ÙÀ½°ú °°ÀÌ Äڵ忡¼ °á°ú¸¦ ³¾ ¼ö ÀÖ´Ù. 1. JavaScript private var state = 0; function Update() { if (state == 0) { // do step 0 state = 1; return; } if (state == 1) { // do step 1 state = 2; return; } // ... } 2. C# using UnityEngine; using System.Collections; public class example : MonoBehaviour { private int state = 0; void Update() { if (state == 0) { state = 1; return; } if (state == 1) { state = 2; return; } } } ±×°ÍÀº yield statement¸¦ »ç¿ëÇÏ´Â °ÍÀÌ ´õ Æí¸®ÇÏ´Ù. yield statement´Â Ưº°ÇÑ Á¾·ùÀÌ´Ù return, ±â´ÉÀº ´ÙÀ½ ½Ã°£¿¡ ºÒ¸®´Â yield statementÈÄ¿¡ ¶óÀο¡¼ °è¼Ó µÇ¾îÁú °ÍÀÌ È®½ÇÇÏ´Ù. 1. JavaScrpit while(true) { // ½ºÅÜ 0À» Ç϶ó yield; //ÇÑ ÇÁ·¹ÀÓÀ» ±â´Ù·Á¶ó // ½ºÅÜ 1À» Ç϶ó yield; // ÇÑ ÇÁ·¹ÀÓÀ» ±â´Ù·Á¶ó // ... } 2. C# using UnityEngine; using System.Collections; public class example : MonoBehaviour { IEnumerator Awake() { while (true) { yield return null; yield return null; } } } ´ç½ÅÀº ¶ÇÇÑ ½ÇÇàÀÌ Áö¿¬µÇ¾î yield statement¿¡ ´ëÇÑ Æ¯º°ÇÑ °ªÀ» Åë°ú ÇÒ ¼ö ÀÖ´Ù Update ƯÁ¤ÇÑ À̺¥Æ®°¡ ¹ß»ýµÉ¶§ ±îÁö ±â´É. |