Creating An Main Menu
To Begin, we will need to create a new scene, so either (File > New Scene) or press (Ctrl + N) to add one. Prior to adding anything else, it is best practice to reset/or set the proper scene hierarchy within the build settings.
Under File> Build Setting, you will find the available scenes that are already within the build along with an index number to the right. If your window shows empty, you can add the current scene to the list by clicking the “Add Open Scenes” button on the right.
For this example, we want the main menu to be first load therefore it shall be top and have the index number of “0”. Then we have the actual game scene second.
Adding the Elements
For my custom start menu, I created a Canvas and imported PNG files to my assets folder.
I needed to convert the imported files to be converted to Sprites (2D and UI). Then within the Canvas, I created several empty image objects, and drag the sprites into the required slots. I also added Animation for the spaceship to add some flare to the main menu.
Making the Start Button
Adding a button is as simple as adding text or image elements, right click the canvas and add button.
What makes the button element such as special class is because of the “On click” attribute. It is able to call upon public methods when the button is click. Knowing this, it is just a simple matter of creating a new C# script containing a public method and Scene management.
Add the newly created script into the Canvas object and one the button element drag the Canvas into the on click slot. On the drop down menu you should be able to select the newly created public method. With this, your newly created button should be functional.