Create Timer – Unity3D (C#)

Create Timer – Unity3D (C#)

A visible or background timer runs on most games. We will create an easy one which ticks seconds. In this tutorial we don’t use any value such as integer, float etc. We just need a GUI text. Let’s create.

Open your project and create a GUIText. Right-Click on hierarchy window, UI/Text.

Screen Shot 2016-06-05 at 16.46.59

Edit its text. This step is important because we will use this text. Set it as your timer beginning value.

Screen Shot 2016-06-05 at 16.50.48

Now create a C# script. In this script, we are going to take the value of GUIText and decrease it by 1 every second. Don’t forget to implement using UnityEngine.UI; lib because Text needs it.

That’s it. Set your UI text as scoreText and run it. We got a “seconds” timer with a simple logic.


©Coffee Break Codes – Create Timer – Unity3D (C#)

Leave a comment

Your email address will not be published. Required fields are marked *

One thought on “Create Timer – Unity3D (C#)