Created
November 27, 2014 02:21
-
-
Save kuanyingchou/7d3d6482f74f64dd0205 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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