Skip to content

Instantly share code, notes, and snippets.

@kuanyingchou
Created November 27, 2014 02:21
Show Gist options
  • Save kuanyingchou/7d3d6482f74f64dd0205 to your computer and use it in GitHub Desktop.
Save kuanyingchou/7d3d6482f74f64dd0205 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class TestCoroutine : MonoBehaviour {
public void Start()
{
StartCoroutine("Co1");
StartCoroutine("Kill");
}
public IEnumerator Kill()
{
yield return new WaitForSeconds(2);
StopCoroutine("Co1");
}
public IEnumerator Co1()
{
Debug.Log("start co 1");
yield return StartCoroutine("Co2");
Debug.Log("end co 1");
}
public IEnumerator Co2()
{
Debug.Log("start co 2");
yield return StartCoroutine("Co3");
Debug.Log("end co 2");
}
public IEnumerator Co3()
{
Debug.Log("start co 3");
for(int i=0; i<5; i++) {
yield return new WaitForSeconds(1);
Debug.Log(i+1);
}
Debug.Log("end co 3");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment