Unity 3.x Game Development by Example Beginner's Guide
上QQ阅读APP看书,第一时间看更新

Time for action – Find the Mesh Renderer component

Does renderer sound familiar to you? We already saw a component called Mesh Renderer when we created our Paddle and Ball Game Objects. If you don't remember, have a look at the following steps:

  1. Select the Ball, if you haven't already.
  2. Look in the list of the components of the Ball in the Inspector panel. There should be one component there called Mesh Renderer.
  3. If you see only the name of the component, click on the gray arrow next to the component name to expand the component.

Aha! What do we have here? Something called Mesh Renderer—it has a checkmark next to it. What happens if you click to uncheck that checkbox?

Go on—try it!

The ball disappeared. No surprises there. We saw something similar happen when we clicked on the checkmark beside an entire Game Object in the last chapter.

But, I wonder, does this Mesh Renderer component have anything to do with the "renderer" we talked about in our DisappearMe script? Checking that checkbox certainly seemed to have the same effect as running a script that said renderer.enabled = false;.

Let's be bold here. We need to figure this out. We'll leave the checkbox unchecked and modify our script to get a solid answer.