Game Development Reference
In-Depth Information
12. Go to Component | Audio | AudioSource . There, create three prefabs for the key ,
Player , and restartButton . Go to Assets | Create | Prefab three imes, and
name all of them as follows: Key , Player , and restartButton .
13. Next, we drag our Player in Hierarchy to the Player Prefab in the Project window.
We will also do the same with Key ; drag our Key in Hierarchy to the Key Prefab in
the Project window.
14. For the restartButton , we need to create a new tag; go to Edit | Project Settings
| Tags . Under Element 5 type RestartButton .
15. Next, create a new GUI Texture object, which is for our replay buton
GameObject | Create Other | GUI Texture and name it restartButton , and in the
object inspector set it as follows:
Tag : RestartButton
Position : x: 0.5 , y: 0.5 , z: 0
Rotation : x: 0 , y: 0 , z: 0
Scale : x: 0 , y: 0 , z: 1
GUITexture:
Texture : Drag-and-drop restartButtonOut.png here
Color : Leave it as default
Pixel Inset :
F X: -64 , Y: -16 , Width: 128 , Height: 32
16. Drag restartButton in Hierarchy and drop to the restartButtonPrefab in the
Project Window, click on the restartButtonPrefab in the Project window, and drag
our TextureButton.js script to restartButtonPrefab . In the Inspector , we add all
objects needed for Texture Button (Script) as follows:
Normal Texture : Drag-and-drop restartButtonOut.png in here
Roll Over Texture : Drag-and-drop restartButtonOver.png in here
Click Sound : Drag-and-drop button_click.aiff here
Key : Drag-and-drop Key Prefab here
Player : Drag-and-drop Player Prefab here
Ok, now we are done; click play to see what we have. Now, when we collect the key
and go inside the door, we will see a restart buton appear; click on this buton and the
game will restart.
 
Search WWH ::




Custom Search