官术网_书友最值得收藏!

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 popped-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 of three different things, you'll be well on your way to getting past the confusing bracket hurdle that many new programmers face.

In order to understand the rest of that line, you need to realize that there is a LOT of code going on behind the scenes that you can't see. It looks like a bunch of pretty pictures to you and me, but the Unity team had to write code to make it look that way. Behind each instance of your GameObject, and behind the Unity program itself, there are thousands of lines of code telling your computer what to show you.

Renderer is one such piece of code. When you set the enabled property of your ball's renderer to false, you're saying that you don't want Unity to draw the triangles in the mesh that makes up your ball.

主站蜘蛛池模板: 望都县| 德令哈市| 蒙城县| 株洲市| 江山市| 托克逊县| 沛县| 河池市| 祁连县| 西乌珠穆沁旗| 江山市| 保靖县| 杭锦后旗| 遂溪县| 思茅市| 石泉县| 秦安县| 台东市| 娱乐| 格尔木市| 普格县| 辰溪县| 武鸣县| 新田县| 株洲市| 介休市| 屏东市| 新龙县| 资源县| 通许县| 乌兰察布市| 江门市| 环江| 万山特区| 嘉鱼县| 静海县| 林州市| 澄江县| 宁海县| 仁怀市| 永和县|