Skip to content

Instantly share code, notes, and snippets.

@neruca neruca/blog20150111-1 Secret
Last active Jan 11, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.