UI Elements
Timer A flexible timer with animations
Timer provides a complete time counting system that is designed for gameplay timers, cooldowns, crafting bars, progress displays, challenge timers, and any UI that needs time tracking.
When smoothing is enabled, the visual bar and text animate toward the target time value.
Name Type Description durationfloatTotal time in seconds currentTimefloatCurrent raw timer value textFormatstringFormat containing 0 placeholder displayFormatDisplayFormatControls numeric or time display isRunningboolTrue while timer is active isCompletedboolTrue when timer completes
Name Type Description autoStartboolStarts timer automatically on Start countDownboolCounts down when true, up when false loopboolRestarts timer after completion isVerticalboolUses vertical fill direction
Name Type Description enableSmoothingboolAnimates fill and text values updateBarOnSecondsOnlyboolUpdates bar only when whole seconds change smoothingDurationfloatAnimation duration
Name Type Description fillRectRectTransformFill anchor or Image fill target valueTextTMP_TextDisplays formatted time
Name Type Description onValueChangedTimerEventFired whenever display value changes onTimerCompleteUnityEventFired when reaching zero or duration onTimerStartUnityEventFired when starting timer onTimerStopUnityEventFired when stopping timer onTimerResetUnityEventFired when timer resets
Name Parameters Description StartTimer()None Starts timer StopTimer()None Stops timer PauseTimer()None Stops counting without events ResumeTimer()None Continues counting ResetTimer()None Resets currentTime and display SetCurrentTime(value)floatSets time and triggers events SetCurrentTimeWithoutNotify(value)floatSets time without events AddTime(value)floatAdds time SubtractTime(value)floatRemoves time GetRemainingTime()None Returns remaining time GetElapsedTime()None Returns elapsed time
using UnityEngine ;
using Evo . UI ;
public class TimerExample : MonoBehaviour
{
public Timer timer ;
void Start ()
{
// 60 second countdown
timer.duration = 60f ;
timer.currentTime = 60f ;
timer.countDown = true ;
timer.enableSmoothing = true ;
timer.textFormat = "{0}" ;
timer.displayFormat = Timer.DisplayFormat.Time_MM_SS;
// Listen to events
timer.onValueChanged. AddListener ( v =>
{
Debug. Log ( "Time: " + v);
});
timer.onTimerComplete. AddListener (() =>
{
Debug. Log ( "Timer finished" );
});
// Start the timer
timer. StartTimer ();
}
void Update ()
{
// Manual controls
if (Input. GetKeyDown (KeyCode.R))
timer. ResetTimer ();
if (Input. GetKeyDown (KeyCode.Space))
timer. StopTimer ();
}
}