In previous chapters, we learned how to tell Unity what to do line by line. In most of our examples, we wrote one instruction per line. I want to move on to something a bit more complex now.
In this chapter, we will cover the following topics:
Loops are an essential technique when writing any software in pretty much any programming language. By using loops, we gain the ability to repeat a block of code X number of times. There are many variants of loops in C#. We will talk about the most common loops:
foreach
loopfor
loopwhile
loop