yield ends method
This is my code:
public void Start()
{
StartCoroutine(test());
}
private IEnumerator test()
{
Debug.Log("test0");
yield return new WaitForSeconds(1f);
Debug.Log("test1");
}
The output is 'test0'. If I wait for 0 seconds the output is 'test0' 'test1' as expected. Why does it act like a normal return (end the method)?
this code works as expected, but perhaps not how you expect it ;)
it's supposed to print "test0", wait 1 second then print "test1" - which is exactly what it does.
what are you trying to do?
Well, for debugging reasons I try to slow down an algorithm (as I already did before in an other project) but for some reason it doesn't work now (as described above)...
Your answer
Follow this Question
Related Questions
Getting a variable timed Interval with coroutine and yield? 0 Answers
IEnumerator instead of LateUpdate in unity 1 Answer
Add an value to a variable after 2 seconds 1 Answer
Using coroutine and texture array to randomly associate textures? 1 Answer
Update() function keeps running AFTER script is disabled... 1 Answer