Skip to main content
2 of 3
Replace unityscript tag with C#, the language used in the code sample.

Why am I not getting stuck in the loop

I'm new to Unity. I was learning coroutines and I wrote this. enter image description here

When the button is pressed the coroutine is called and it enters the 'while' loop. When I leave the button it stops the coroutine. Shouldn't it get stuck in the 'while' loop as it is an infinite loop ? Why?