I copied this code straight from reference: (http://unity3d.com/support/documentation/ScriptReference/index.Writing_Scripts_in_Csharp.html)
using UnityEngine; using System.Collections; public class PauseScript : MonoBehaviour { public void Awake() { Do(); print("This is printed immediately"); }
IEnumerator Do()
{
print("Do now");
yield return new WaitForSeconds(2);
print("Do 2 seconds later");
}
}
I attached it to a cube prefrab and run it, mysteriously the line inside Do() never get executed... Then I tried the java version of the sample code, that worked fine...
Do (); print ("This is printed immediately");
function Do () { print("Do now");
yield WaitForSeconds (2);
print("Do 2 seconds later");
}
Could it be any setting in unity that I missed?? Any ideas??
Thanks guys..