Learn to code by making a 2D Space shooter game.

Suleiman Abdullah
3 min readJan 4, 2022

Objective: Understand UI While Setup Score Text UI.

UI stands for the User Interface, UI plays a major role in our game to help the user understand what’s going on in our games.

The first step left click in the Hierarchy go to < UI <Text when selecting text there are two texts but let's choose a text for simplicity.

When creating UI in unity by default unity create canvas and EventSystem, canvas is a white panel that contains all component that makes UI eg text, etc. And EventSystem is the component that enables us to hover on the button, toggle, etc.

The next thing we need to set up is text color and fonts size if we leave the text like this we won't be able to see our text since the background is black and so our text.

If we build our game to mobile or tablet with the different size we will have the issue where some part of our canvas component disappears/is cut out.

To solve this issue select the text component to go to Rect Transform below, to the left there is the box left click, it will prompt the box with anchor position to snap the text whether to the top-bottom, etc.

Since we want to snap our text to the top right Conner, we will hold the alt key left click after we select the anchor position in the prompt window to snap our text to the position of or anchor choice.

If we resize the screen the text component wont disappear again.

If you notice when we resize the screen the text remains the same size, we want the text to resize proportionally to the screen size.

To solve this select the canvas, go the Inspector <Canvas<UI Scaler Mode <left click the dropdown < select Scale With Screen Size.

Last, lest rename our text and text Object, to do this select text Object and go the text component rename it then select the text Object rename it to Score_Text.

--

--

Suleiman Abdullah

Self taught Unity Developer, who is passion about making games ,and he loves Math For Game Development