Skip to content
eisclimber edited this page Feb 11, 2024 · 2 revisions

Timer

class in ExPresSXR.Misc.Timing / Extends MonoBehavior
Component added via Component Menu

Description

A simple component that acts as a timer that will signal upon timeout.

Members

Public Properties

  • float _waitTime = DEFAULT_WAIT_TIME: How long the timer takes to timeout. Must be greater than 0.0f.
  • float remainingTime: (Readonly) Returns the remaining time of the timer. If the timer is was not started or timed out, the value will be the value of TIMER_INACTIVE_WAIT_TIME.
  • bool timerPaused: If the timer is paused or not.
  • bool running: If the timer is actively is counting down, meaning it was started and is not paused.
  • bool autoStart: If true, will start the timer during OnAwake()...
  • bool oneShot: If false, the timer will restart after timeout.

Public Methods

  • void StartTimer(float duration = -1.0f): (Re-)starts the timer with duration, setting waitTime in the process. If duration is <= 0.0f the value of waitTime is used.
  • void PauseTimer(bool paused): Starts the timer using waitTime. /// Prevents the need to provide a value if invoked via UnityEvents.
  • void ResumeTimer(): Continues a paused timer or sStarts the timer using waitTime.
  • void SetTimerPaused(bool paused): Pauses or unpauses the timer, maintaining it's current waitTime (and not starting it, if not running)
  • void PauseTimer(): Pauses the timer if possible.
  • void UnpauseTimer(): Unpauses the timer if possible.
  • void StopTimer(): Stops and resets the timer whilst not emitting the timeout event.

Events

  • UnityEvent OnStarted: Event that is triggered when the timer was started. A started timer automatically be unpaused.
  • UnityEvent OnTimeout: Event that is triggered when the timer times out.
  • UnityEvent<bool> OnPaused: Event that is triggered when the timer is paused. The parameter is it is paused or not.

Constants

  • float TIMER_INACTIVE_WAIT_TIME = -1.0f: Value of remainingTime when the timer is not active.
  • float DEFAULT_WAIT_TIME = 1.0f: Default wait time.

ExPresS XR Wiki

Tutorial Pages

Code Documentation

Clone this wiki locally