1 2 3 4 5 6 7 8 9 10 11 12 13 14 | using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Start() { print("Starting " + Time.time); StartCoroutine(WaitAndPrint(2.0F)); print("Before WaitAndPrint Finishes " + Time.time); } IEnumerator WaitAndPrint(float waitTime) { yield return new WaitForSeconds(waitTime); print("WaitAndPrint " + Time.time); } } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { IEnumerator Start() { print("Starting " + Time.time); yield return StartCoroutine(WaitAndPrint(2.0F)); print("Done " + Time.time); } IEnumerator WaitAndPrint(float waitTime) { yield return new WaitForSeconds(waitTime); print("WaitAndPrint " + Time.time); } } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { IEnumerator Start() { StartCoroutine("DoSomething", 2.0f); yield return new WaitForSeconds(1); StopCoroutine("DoSomething"); } IEnumerator DoSomething(float someParameter) { while (true) { print("DoSomething Loop"); yield return null; } } } | cs |
StartCoroutine( 함수(매개변수) );
StartCoroutine( "함수", 매개변수 );
IEnumerator 함수명();
#StartCoroutine http://docs.unity3d.com/ScriptReference/MonoBehaviour.StartCoroutine.html
#StopCoroutine http://docs.unity3d.com/ScriptReference/MonoBehaviour.StopCoroutine.html
#코루틴 http://docs.unity3d.com/ScriptReference/Coroutine.html
#유니티 4버전 버그로 함수로 시작된 코루틴은 StopCoroutine("함수명") 과 같은 메시지 방식으로는 멈추지 못 합니다.
320x100
'- > Unity3D 5.x' 카테고리의 다른 글
유니티3D, Mathf (0) | 2015.05.12 |
---|---|
유니티3D, Invoke함수 (0) | 2015.04.09 |
LitJSON은 float 을 지원하지 않는 것으로 보인다. (0) | 2015.03.05 |
Physics.Raycast() 함수 (0) | 2015.01.20 |
Collider (0) | 2015.01.19 |
댓글