Overview: Coroutines & Yield page

Hi, on this page:
http://docs.unity3d.com/412/Documentation/ScriptReference/index.Coroutines_26_Yield.html
the penult script it’s saying that we can call coroutines without StartCoroutine in c#:

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
IEnumerator Do() {
print("Do now");
yield return new WaitForSeconds(2);
print("Do 2 seconds later");
}
void Example() {
Do(); // <------ doesn't work
print("This is printed immediately");
}
}

But it doesn’t work, at least for me…

You must always use StartCoroutine in C#, so the code there is wrong.

–Eric

1 Like

Thanks again Eric, that’s what I thought.