Let's fill up this main menu with three buttons: Play, Options, and Exit. First, let's create an empty GameObject that will hold the three buttons:
Select our
Main
GameObject in the Hierarchy view.Create a new empty child by pressing Alt + Shift + N.
Rename the new child to
Buttons
.
Ok. We can now create our first button.
Drag Simple Button (1) from our Prefab Toolbar inside our Buttons
GameObject in the Hierarchy view, as shown in the following screenshot:
A new button appears in the Game view, as follows:
Select UI Root
| Buttons
| Control – Simple Button
. Your Hierarchy view should look like this:
As shown in the preceding screenshot, our new button is composed of two GameObjects:
Control – Simple Button (1): The main object, with these components attached:
UISprite: This renders the button's sprite, set to the
Button
spriteUIButton: This handles different button states, colors, and events
Box Collider: This is required to detect mouse and touch interactions
Label ...