Ease of Building UI Elements in Unity

User interface elements are easily added to your project by adding components within the hierarchy and editing within the inspector lets see an example:

When you right click and use the drop down menu for the UI you have some options for now we will use text to add a Score. This adds a canvas to the scene. We will add a script to this element.

Then change the text element name to “Score_Text”. we can then select and adjust the settings within the inspector.

With both elements made now we can add some code to the script. within the player script we want the player to gain a score so like 10 for each enemy shot.

Within Player Script

This communicates with our UI manager to run the method “AddScore”

Within Enemy Script

This will add 10 to the score once an enemy is destroyed, I have placed this piece code after the Destroy this game object line.

Within the UI manager
Score in Action

Aspiring Unity Developer