- Unity 4.x Game Development by Example Beginner's Guide
- Ryan Henson Creighton
- 216字
- 2025-03-31 04:02:05
Lick it and stick it
Return to Unity. You should still see your DisappearMe
Script in the Project panel. To attach it to the ball, drag-and-drop the file over the Ball GameObject in the Hierarchy panel.
If drag-and-drop isn't your thing, you can also select the Ball GameObject, and navigate to Component | Scripts | Disappear Me from the menu. You could also click on Add Component in Inspector, click on Scripts, and then choose the DisappearMe script from the resulting list. Once you do this, it may not look as if anything happened. To confirm that you did it correctly, click on the Ball in the Hierarchy. At the bottom of the Inspector panel where components of the Ball are listed, you should see your DisappearMe
Script .

Disappear me!
Uncheck the Maximize on Play button in the Game view to experience the full effect of your script. (Cue circus music) And now, ladies and gentlemen, thrill to the astounding spectacle that you have created with a single line of code! Press the Play button to test your game, and watch with amazement as your Ball disappears!
What just happened?
A good magician never reveals his tricks, but let's break down that piece of code we wrote to see what's going on behind the scenes.