Timer

1 min read

Updated on November 21, 2025

Introduction

This component is solely used in the Crafter component. It does not rely on other components from this system however, so you could use this Timer class for any other logic that would require a Timer.

Setting up

Setting up just requires adding this component to a gameobject.
Crafter will automatically add this component to the gameobject.

Settings

Mode
Count Down – Counts the Timer down from the set time.

Count Up – Counts the Timer Up from 0 to the set time.

Display Format
Seconds – Only display seconds.

MinutesSeconds – Display Minutes and Seconds.

HoursMinutesSeconds – Display Hours, Minutes and Seconds.

Detailed – Displays the characters such as 5h : 24m : 15s. This mode can also hide leading zeros when the time is less. For example if the total time was 1 hour and 45 minutes, when below an hour it would show 59m : 59s and not 0h : 59m : 59s.

Show Milliseconds
Display the Milliseconds, this applies to all modes except detailed.

Hide Leading Zeros
In Detailed mode, hide the characters that are equal to 0. For example if the total time was 1 hour and 45 minutes, when below an hour it would show 59m : 59s and not 0h : 59m : 59s.

Time Splitter
Which character to put in between the time segments. Such as : or /.

Time Text
Assign a TextMeshProUGUI component to display the current time.

Fill Image
Assign an Image component to display the current time using the fill.

Event

On Timer Complete Event
Triggers when the Timer has finished

Scripting

//Action

//Triggers when the Timer has finished
//public Action OnTimerCompleteAction;

/// <summary>
/// Initialise the Timer without starting it. This will also refresh the UI
/// </summary>
/// <param name="duration"></param>
public void InitTimer(float duration)

/// <summary>
/// Start the timer with a given duration
/// </summary>
/// <param name="duration">The duration of the timer</param>
public void StartTimer(float duration)

/// <summary>
/// Start the timer midway through, with a given duration, and current value
/// </summary>
/// <param name="duration">The duration of the timer</param>
/// <param name="current">The current value the timer should start at</param>
public void StartTimerMidway(float duration, float current)

/// <summary>
/// Stop the timer and reset it
/// </summary>
public void StopTimer()

/// <summary>
/// Pauses the timer
/// </summary>
public void PauseTimer()

/// <summary>
/// Resumes the timer
/// </summary>
public void ResumeTimer()

/// <summary>
/// Hide and Unhide the text displaying object
/// </summary>
/// <param name="display"></param>
public void DisplayTextObject(bool display)

/// <summary>
/// Refresh the time UI
/// </summary>
public void UpdateUI()