How to Create UI Elements in Unity

Creating a good looking UI is very simple in Unity. Much like painting, to create a UI you need to have a canvas.

To create a canvas right click in the hierarchy and find UI >> Canvas

The canvas is where all your UI elements will be displayed. Now to create the UI it is as simple as deciding what you want your UI to look like and adding it to the canvas.

As an example let’s create a main menu screen.

First right click on canvas and select UI >> Text

Now modify the text in the inspector. It will display Main Menu for text. The text will be white and we will increase the size. You may want to change the horizontal and vertical overflow to the overflow option so the text will not be cut off by the text box.

At the top of the inspector there is an option to choose an anchor point for your text. This will keep the text in the spot it is anchored.

Now let’s add a start button.

Just like with the canvas and text select UI >> Button

Now move the button to where you want it to be located and make sure you anchor it to that spot

The button will be given its own text box. This will be where you give the button the start text.

In the inspector for the button you can give the button a highlighted color. This will be the color the button turns when the player hovers over it with their cursor.

For now this example these are the only elements that the UI will have.

What you will also want to make sure that you do is to go to the canvas and change the UI Scale Mode to Scale with Screen Size.

This will allow the UI to keep a consistent look regardless of the size of the screen.

Unity Game Developer and C# Programmer