Creating a well-formatted timer

In this recipe, we are going to create a timer that displays time on the screen in minutes and seconds. The benefit of using a more precise timer is the ability to provide the player with a more precise indication of time. This is particularly helpful when there are moments during the game that can take up a considerable amount of time. Having time displayed in a familiar format also assists the player to easily recognize and respond to the amount of time remaining. We will use Text (Script) and develop a script to achieve this goal.

How to do it...

  1. First of all, we need to create new UI text that will display our timer. Right-click on the Hierarchy panel and then navigate to UI | Text. Rename it to Well Formatted ...

Get Unity UI Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.