Our windows are draggable pop ups; we should add a close button in the top-right corner:
In order to do this quickly and easily, we can use a component called UIForward Events
. It's a legacy component—it is now recommended that you use UIEvent Trigger
instead. We'll try both because it's good that you understand how they work.
Before we continue, let's create the close button for our main menu:
Select our
UI Root
|Main
|Buttons
|Exit
GameObject.Hit Ctrl + D to duplicate it.
Rename the new duplicate to
Close
.Remove its attached
UIPlay Tween
component.Change the
UISprite
Size to 100 x 100.Set its Transform position to {800, 400, 0}.
Select our
UI Root
|Main
|Buttons
|Close
|Label
GameObject.Rename it to
X
.Set its
UILabel
Text to a lowercasex
character to look like a cross.Change its
UILabel
Font Size to 55.
The close button is ready. Let's see how the UIForward Events
component works.