Hello guys,
I’m trying to understand how coroutines work. I’ve already read all of the documentation that unity has.
Here is what I’m trying to do:
public void Awake()
{
StartCoroutine(cotest());
}
public IEnumerator cotest()
{
for (int x = 0; x <= 1000; x ++)
{
for (int y = 0; y <= 1000; y ++)
{
//do something
}
Debug.Log("I'm in!!!");
yield return new WaitForSeconds(0.1f);
}
}
I want the text “I’m in!!!” to be shown on the console 1000 times. But it only shows once.
It’s has if the the code never comes back to continue the yield.
Can you guys help me? What am I doing wrong?
That's because you also have collapse turned on, which collapses duplicate messages in the console, but are now changing the message each time.
– anon73820239It worked. I guess the Debug.Log only show a new message if it's different from the last one. Thank you very much :)
– juliobdsWho to vote me down...? :(
– anon31163336It wasn't me for sure :(
– juliobdsThanks juliobds. :)
– anon31163336