To add button to the Menu, simply select the Canvas, right click, UI, Button.
This add a button and a text for the button
Rename the button “New Game Button” and move it to the right of our image
The logic we need now is create a method, and when we click the button load the Game scene.
There are many options for the Button, such as changing color when we hover over it, change color when clicking or releasing, etc.
I won’t talk about all of these options, but it’s good to know that these kinds of customizations exist.
Now we have to think this : we have UI Manager script, and because button is part of UI, we can drag into Canvas that script.
Let’s lokk what happen
The logic about have a UI manager and use it for the UI is absolutely sense
does it make sense to have empty fields that have never been used?
Is better create another script “Main Menu” only for this menu, and to make things clean and organize inside Scripts folder we create another folder and called “Main Menu”
Another thing to do is go to the Canvas, and change Canvas Scaler to Scale with Screen Size.
After this change it can be happen that the Button now is move to the center, just reset is position with move tool
What we need now is open the Main Menu script and create a method to call when we click the Button
To load the scene, we need to add the Scene to Build Setting as we did before with Game Scene, but we have to set the main menu as the FIRST SCENE, and the GAME SCENE as the second.
To do this, open the Build Setting, DELETE the current scene, then add Open Scene and DRAG the Game Scene into Build Setting
Now we have Main Menu (0 Index), and Game Scene (1 Index)
Now into script
In LoadScene() we can pass or a string for the name or an int for the Index
Last part is in the next session!