We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9
COROUTINE
PRESENTER: DUONG HOANG THANH
COROUTINE
• A special type of function used in Unity
• to stop the execution until sometime or certain condition is met, • and continues from where it had left off. • It is essentially a function declared with a return type of IEnumerator • and with the yield return statement included somewhere in the body. • The yield return line is the point at which execution will pause and be resumed the following frame • The start of a coroutine corresponds to the creation of an object of type coroutine.
START & STOP
COROUTINE public Coroutine StartCoroutine(IEnumerator routine); public void StopCoroutine(IEnumerator routine); public void StopAllCoroutines();
IEnumerator MyCoroutine(){yield return null;}
IEnumerator MyCoroutineOneParam(int i){yield return null;} IEnumerator MyCoroutineManyParams(int i, int j){yield return null;} COROUTIN E VS NORMAL FUNCTIONS WAIT FOR SECOND WHAT YOU CAN YIELD
• null – the coroutine executes the next time that it is eligible
• WaitForEndOfFrame – the coroutine executes on the frame, after all of the rendering and GUI is complete • WaitForFixedUpdate – causes this coroutine to execute at the next physics step, after all physics is calculated • WaitForSeconds – causes the coroutine not to execute for a given game time period • WWW – waits for a web request to complete (resumes as if WaitForSeconds or null) • Another coroutine – in which case the new coroutine will run to completion before the yielder is resumed • yield break – immediately stops the coroutine. • … COROUTINE UPDATE
•Coroutine is tied to the
MonoBehaviour component that hosted the call. IMPLEMEN T BLINKING IMPLEMENT CONVERSA TION
Learning C by Developing Games With Unity 5 X Develop Your First Interactive 2D Platformer Game by Learning The Fundamentals of C Second Edition Greg Lukosek Instant Download