Skip to content

Instantly share code, notes, and snippets.

@neruca
Last active January 11, 2016 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neruca/5cabadf8686ab94d1474 to your computer and use it in GitHub Desktop.
Save neruca/5cabadf8686ab94d1474 to your computer and use it in GitHub Desktop.
Unity Coroutine Exampe 1
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