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

The Renderer class

The Renderer class lists a bunch of stuff that might look like so much gibberish to you. It has these lists:

  • Variables
  • Messages sent
  • Inherited variables
  • Inherited functions
  • Inherited class functions

From that list, the only familiar word might be "functions", which we just learned are reusable bundles of code (or endlessly eatable sandwiches, if you prefer). As we write more code in this chapter, we'll come to understand what variables are. For now, focus on the things listed under the Variables section.

One of the variables is called enabled. Do you remember when you wrote renderer.enabled = false;? You've already used a variable, perhaps without knowing it. And, check it out—some of the other things that we noticed in the Mesh Renderer component are listed here. There are variables called castShadows and receiveShadows, which we saw as checkboxes in the Inspector panel. There are also some material-related variables. At the bottom of the list, there's a variable called isVisible , which appears to do something different than the enabled variable.

Have a go hero - Pulling the wings off of flies

If you were the type of kid who disassembled your parents' clock radio, or got up close and personal with the insects in your backyard to see what made them tick, this is your time to shine. The Language Reference is your gateway to every special reserved word ("keyword") in the Unity language. Try clicking on the enabled variable in that list. The resulting page not only repeats the explanation of the variable, but it also provides an example of how you might use that variable in code. You can even use the drop-down lists on the right to see the C# and Boo translations. (Go ahead check them out! Fortune favors the bold.)

If you're wired a certain way, you've already thrown this book down and are eagerly scouring the Language Reference looking for code you can mess around with. That's okay. We'll be here when you get back. If you are still a little wary of this foreign language and would like a little more guidance using it, read on.

主站蜘蛛池模板: 台东县| 民乐县| 阳春市| 磐石市| 萍乡市| 长春市| 苗栗县| 铁岭市| 永年县| 兴宁市| 南昌县| 科技| 桂林市| 辉南县| 乌鲁木齐市| 韩城市| 泰州市| 泸州市| 龙泉市| 定西市| 郑州市| 礼泉县| 安平县| 许昌县| 宝丰县| 工布江达县| 安溪县| 开远市| 海林市| 星子县| 余干县| 湾仔区| 进贤县| 武城县| 尉犁县| 吉木乃县| 宕昌县| 贡山| 梨树县| 天门市| 安阳县|