- Home /
WaitForSeconds problem with Unity Pro
... StartCoroutine(SomeMethod()); Debug.Log("Works fine"); ...
IEnumerator SomeMethod() { Debug.Log("Works fine"); yield return new WaitForSeconds(1);
Debug.Log("Never called"); }
This code above used to work till I upgrade Unity to pro, so I believe the code it-self is ok.
But what could I be doing wrong? Could be a new player setting that comes with pro?
If I change WaitForSeconds for WaitForEndOfFrame or WaitForFixedUpdate, it works. Only WaitForSeconds stuck it.
Does it through an error? I mean what exactly you mean by stuck?
Answer by Ashkan_gc · Apr 26, 2011 at 01:48 AM
it's really strange and i think there is a problem in another side, for example in your project settings/time or ... something changed (timescale or ...) and that could be the source of your problem cause the code is totally ok!
Weird... The timescale was 0, but I never changed it. Thanks, man.
Answer by cmasterenko · Apr 26, 2011 at 02:35 AM
Have you tried making a new test project with primitives and just that code to see how it functions, I had some script just randomly stop working for me before, but it worked when I rebuilt my project from scratch.
Answer by Silverfell 1 · Apr 26, 2011 at 02:18 AM
Random thoughts:
1) You're not trying to call the coroutine from Update, are you? That won't work.
2) Try yield return new WaitForSeconds(1.0F); <- just in case.
Actually you can start coroutines from Update, you just can't have "yields" in the function.
Your answer
Follow this Question
Related Questions
StartCoroutine important for using yield? 1 Answer
JS Wait for a function to complete - no WaitForSeconds 1 Answer
Coroutines and states 1 Answer
What is wrong with this use of WaitForSeconds? 1 Answer
Alternative to "yield return WaitForSeconds()" in Coroutine with .NET Framework (Unity 2018.4) 0 Answers