How big is your locker?

Some Collections, like Built-in Arrays, have a set size. You need to tell Unity how many things you're putting inside, and that number can never change. Other Collections, like Generic Lists, can take whatever we throw at them—their length is elastic, and they don't have to have a set size. Which approach is better? As you'll see, there are advantages and disadvantages to each.

You'll remember that when we define a variable (a bucket that can hold one thing), we're actually carving out a storage locker in the computer's memory. By typing the variable (giving it a type), we're telling the computer how big that storage locker needs to be. An int variable needs a different amount of room in memory than a string variable or ...

Get Unity 4.x Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.