Examining the code

Let's look closely at the line of code that we wrote:

renderer.enabled = false;

The semicolon at the end of the line is like the period at the end of a sentence. Nearly all single-line statements must end in a semicolon or the code might break. When code breaks, Unity uses a special pop-up window called the console to tell us about it. When you have code that throws an error, we say there is a bug in your code.

Tip

Semi-confusing

So why doesn't the function declaration have a semicolon? Why don't the curly braces each have one? It's because they're a different beast. They're not a single line of code—they're more like a house where code lives. If you start seeing the declaration and statement block as one complete thing instead ...

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.