using System; using UnityEngine; /// /// Contains extension methods related to s. /// namespace UnityTimer { public static class TimerExtensions { /// /// Attach a timer on to the behaviour. If the behaviour is destroyed before the timer is completed, /// e.g. through a scene change, the timer callback will not execute. /// /// The behaviour to attach this timer to. /// The duration to wait before the timer fires. /// The action to run when the timer elapses. /// A function to call each tick of the timer. Takes the number of seconds elapsed since /// the start of the current cycle. /// Whether the timer should restart after executing. /// Whether the timer uses real-time(not affected by slow-mo or pausing) or /// game-time(affected by time scale changes). public static Timer AttachTimer(this MonoBehaviour behaviour, float duration, Action onComplete, Action onUpdate = null, bool isLooped = false, bool useRealTime = false) { return Timer.Register(duration, onComplete, onUpdate, isLooped, useRealTime, behaviour); } } }