UI Elements
Countdown
A timer component with animated digit transitions
Countdown is a fully animated time display that counts down hours, minutes, and seconds with smooth sliding digit transitions.
| Name | Type | Description |
|---|
hours | int | Initial hour value (0 to 23) |
minutes | int | Initial minute value (0 to 59) |
seconds | int | Initial second value (0 to 59) |
separator | string | Character used between time sections |
| Name | Type | Description |
|---|
autoStart | bool | Starts countdown automatically on enable |
showHours | bool | Toggles hour display |
showMinutes | bool | Toggles minute display |
showSeconds | bool | Toggles second display |
useUnscaledTime | bool | Uses unscaled delta time |
| Name | Type | Description |
|---|
useDynamicSpacing | bool | Automatically distributes digit sizes |
separatorSpacing | float | Spacing width between separators (fixed mode) |
digitSpacing | float | Spacing between digits (fixed mode) |
| Name | Type | Description |
|---|
animationDuration | float | Duration of digit slide transition |
slideDistance | float | Vertical distance digits slide during change |
animationCurve | AnimationCurve | Curve used for sliding transitions |
| Name | Type | Description |
|---|
stylingSource | StylingSource | Source for font and color styling |
stylerPreset | StylerPreset | Preset used for styling lookup |
fontColor | ColorMapping | Color used for digits |
timerFont | FontMapping | Font used for digits |
fontSize | float | Size of the digit text |
fontStyle | FontStyles | Font style flags for TextMeshPro |
| Name | Type | Description |
|---|
onTimerComplete | UnityEvent | Fired when countdown reaches zero |
onTimeChanged | UnityEvent<int, int, int> | Fired whenever hour, minute, or second value changes |
| Name | Parameters | Description |
|---|
ResetTimer() | None | Resets time and stops countdown |
SetTime(newHours, newMinutes, newSeconds) | int, int, int | Updates timer values and refreshes display |
RefreshDisplay() | None | Rebuilds layout and redisplays digits |
StartTimer() | None | Starts countdown |
PauseTimer() | None | Pauses countdown |
GetCurrentTime() | None | Returns remaining time in seconds |
IsRunning() | None | Returns true if the timer is active |
using UnityEngine;
using Evo.UI;
public class CountdownExample : MonoBehaviour
{
public Countdown countdown;
void Start()
{
// Set custom start time
countdown.SetTime(1, 20, 45);
// Listen for time changes
countdown.onTimeChanged.AddListener((h, m, s) =>
{
Debug.Log("Time changed: " + h + ":" + m + ":" + s);
});
// Listen for completion
countdown.onTimerComplete.AddListener(() =>
{
Debug.Log("Countdown finished");
});
// Start the timer
countdown.StartTimer();
// Pause or resume
countdown.PauseTimer();
// Reset
countdown.ResetTimer();
}
}