Search Results for

    Show / Hide Table of Contents

    TimerEvent

    Set events based on time with a countdown timer.

    namespace GarageKit
    public class TimerEvent : MonoBehaviour
    

    Inheritance

    TimerEvent -> MonoBehaviour

    Methods

    Check if the timer has started

    public bool IsStarted { get; }
    

    Check if timer is running

    public bool IsRunning { get; }
    

    Timer remaining time (seconds)

    public int CurrentTime { get; }
    

    Timer elapsed time (seconds)

    public float ElapsedTime { get; }
    

    Timer elapsed event per second

    public event OnTimerDelegate OnTimer
    

    Timer completion event

    public event OnCompleteTimerDelegate OnCompleteTimer
    

    Start timer

    public void StartTimer(int countTime, float delayTime = 0.0f, bool autoDestroy = false)
    

    Stop timer

    public void StopTimer()
    

    Resume timer

    public void ResumeTimer()
    

    Reset timer

    public void ResetTimer(bool andStart)
    

    Example

    • /Scenes/Examples/EventExample.unity
    GameObject obj = new GameObject("TimerEventObject"); 
    obj.AddComponent<TimerEvent>();
    obj.GetComponent<TimerEvent>().OnTimer += (sender, sec) => {};
    obj.GetComponent<TimerEvent>().OnCompleteTimerEvent += (sender) => {};
    obj.GetComponent<TimerEvent>().StartTimer(10); // count down 10 sec
    
    • Edit this page
    In this article
    Back to top Generated by DocFX