Adding a Main Menu to our UI

Let’s create a new scene and name it MainMenu as shown above.

Let’s create our canvas and an image for our title screen logo.

Again, I’ll be using the assets provided by GameDevHQ, but you can use any image you like here.

We’ll go ahead and 0,0,0 the position, assign the sprite, set our width and height to match our native Image Size (shown at the bottom right of above gif in inspector window), and select “Preserve Aspect”.

We’ll set up some properties on our canvas as shown above.

We’ll add in our Nebula background and resize it to fit our screen.

Create the New_Game_button and rename it.

Go ahead and select a highlighted color for the New_Game_button.

Position the New Game button as desired in the scene view.

Let’s open our build settings and not only add this MainMenu scene, but reorder our scenes so that MainMenu is index 0.

Let’s create a new script called MainMenu and add it to our Canvas game object.

We’ll add our SceneManagement using statement and a LoadGame() method to, you guessed it, load our scene.

With our scenes newly reordered, our “Game” scene is index 1 and that is the value we will need to use.

The Unity editor makes it easy for us to connect our button to our LoadGame() method on the MainMenu script.

We select our button, add an “On Click ()” event, drag the canvas object into the field (MainMenu script lives on Canvas game object) and select the LoadGame() method from the function menu dropdowns.

That’s it, run the game and the Main Menu should load up and work correctly!

In the next article we will work on enemy explosions.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Wordle — 236 6/6

Dummy shopping cart project with focus on flexbox for the layout and vanilla javascript for the…

Flexible piping in python with Pipey

OV Exclusive —  Testnet, P76, and the Month Ahead

Making agile open-source #RetroOnAgile

Streaming Video in Unreal Engine 4 — Part 2 — Hosting on AWS EC2 and S3

READ/DOWNLOAD#- Introduction to Networks v6 Companion Guide FULL BOOK PDF & FULL AUDIOBOOK

Launch Tableau on AWS in minutes with Cloud Formation

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
GameDev Dustin

GameDev Dustin

More from Medium

Adding Shield Strength And Color Change When Damaged And Tying It To UI Sprite Sheet

Scripting our greybox prototype

Tap & Hold & Rapid Prototyping w/ New Unity Input System

Creating a Sci-fi Lab Room