Unity 4.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 GameObjects. If you don't remember, have a look:

  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 on it to uncheck that checkbox?

Go on—try it!

Time for action – find the Mesh Renderer component

The ball disappeared. No surprises there. We saw something similar happen when we clicked on the checkmark beside an entire GameObject in the previous 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.