while versus for loops

Both while and for loops do the same thing. I bet you are wondering why we should even bother learning them both. A for loop is great for iterations through arrays and lists. A while loop is great for holding code execution until a condition isn't met.

I don't want you to worry about while loops for now. We will go through more complex examples when you learn about coroutines in Unity. A coroutine is a special type of method in Unity that can run through an infinite loop without crashing. Let's forget it for a few chapters. We will definitely use them in the second half of the book, when you will be building your first game!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset