-
-
Save neruca/5cabadf8686ab94d1474 to your computer and use it in GitHub Desktop.
Unity Coroutine Exampe 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class CoroutineTest : MonoBehaviour { | |
// Use this for initialization | |
void Start () { | |
Debug.Log ("CountStart !!"); | |
StartCoroutine (CountFrame1To5 ()); | |
StartCoroutine (CountFrame201To205 ()); | |
Debug.Log ("CountEnd !!"); | |
} | |
IEnumerator CountFrame1To5 () { | |
int i = 0; | |
Debug.Log ((++i).ToString ()); | |
yield return null; | |
Debug.Log ((++i).ToString ()); | |
yield return null; | |
Debug.Log ((++i).ToString ()); | |
yield return null; | |
Debug.Log ((++i).ToString ()); | |
yield return null; | |
Debug.Log ((++i).ToString ()); | |
} | |
IEnumerator CountFrame201To205 () { | |
int i = 200; | |
Debug.Log ((++i).ToString ()); | |
yield return null; | |
Debug.Log ((++i).ToString ()); | |
yield return null; | |
Debug.Log ((++i).ToString ()); | |
yield return null; | |
Debug.Log ((++i).ToString ()); | |
yield return null; | |
Debug.Log ((++i).ToString ()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment