In the Coroutines & Yield script reference, there is code snippet:
public class example : MonoBehaviour {
IEnumerator Do() {
print("Do now");
yield return new WaitForSeconds(2);
print("Do 2 seconds later");
}
void Example() {
Do();
print("This is printed immediately");
}
}
When I ran this example, the body of Do() didn’t execute. Tracing in the debugger showed that execution seemed
to jump to the opening brace of Do(), then immediately returned back to where execution left off in the calling code. Calling StartCoroutine(Do()) worked as expected. Is this an error in the documentation?