Last active
August 29, 2015 14:24
-
-
Save miguel12345/27b7db69cd17a3128ae8 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 System.Collections; | |
//Shouldn't we see the Debug.Log ("End printing") ? | |
public class EnumTest : MonoBehaviour { | |
static int a = 0; | |
IEnumerator printRoutine = null; | |
void Start() { | |
StartCoroutine (main ()); | |
StartCoroutine (endPrinterAfter (4.0f)); | |
} | |
IEnumerator endPrinterAfter(float seconds) { | |
yield return new WaitForSeconds (seconds); | |
StopCoroutine (printRoutine); | |
} | |
IEnumerator main() { | |
Debug.Log ("Begin printing"); | |
printRoutine = printer (); | |
yield return StartCoroutine (printRoutine); | |
Debug.Log ("End printing"); | |
} | |
IEnumerator printer() { | |
while (true) { | |
Debug.Log("Printing "+(a++)); | |
yield return new WaitForSeconds(0.5f); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment