My First Idle Game | Update Text UI in Unity | Lesson 3

Опубликовано: 03 Март 2026
на канале: Greg Moss
1,811
38

Create a fun Idle Clicker Game using C# and Unity. In this lesson we learn to Update UI Text in Unity by setting up GameObject references in our C# script.

Get the full course here:
https://FirstClassGameStudios.com/shop

Why make an Idle Game?
We have chosen to create an idle game for our first project. Idle games are great first games for several reasons:
• It is an easy game design to understand
• It is technically easy to make a simple idle game
• You can make an idle game out of almost any activity. There are infinite possibilities when you make an idle game.
• It also allows a lot of creative freedom to make it your own with very effort
• Idle games give you a great opportunity to publish a game or game course while you are relatively new to game development.

What Kind of Idle Game are we making?

Clicker Heroes is the game we are modeling our game design after. So please take a few minutes to download Click Heroes on your Apple or Android phone so you can learn the mechanics.

Updating the Text field
Now we are ready to write the code we need to update our text field on screen. To do this, simply add the following line of code after where we increment the gold counter. This means every time we increment gold, the text on screen will be updated.

goldText.text = gold.ToString();

Notice that we must add the ‘.tostring()’ method call. This is because gold is an integer and our text component is expecting a string. Calling ToString() converts the integer to a string. Then we can set our text property on the goldText object to its value.