timingunit - eisclimber/ExPresS-XR GitHub Wiki
Class in ExPresSXR.Misc.Timing
Inherits from System.Object
Represents the internal logic of a timer counting down time.
Must be updated manually to process. This should ideally be done in the FixedUpdate() function providing Time.fixedDeltaTime.
Important: Declare and instantiate the timing unit to prevent null errors: private TimingUnit _timingUnit = new();
public class TimingUnit| Name | Description |
|---|---|
| DEFAULT_WAIT_TIME | Default wait time. |
| OnStarted | Event that is triggered when the timer was started. A started timer automatically be unpaused. |
| OnTimeout | Event that is triggered when the timer times out. |
| TIMER_INACTIVE_WAIT_TIME | Value of remainingTime when the timer is not active. |
| TIMER_USE_DEFAULT_WAIT_TIME | Value used internally to signal starting with the default wait time. Can be any value less or equal to zero. |
| Name | Description |
|---|---|
| StartTimer(float) | (Re-)starts the timer with duration, setting waitTime in the process. |
| If duration is less or equal to 0.0f the value of waitTime is used. | |
| StopTimer() | Stops and resets the timer whilst not emitting the timeout event. |
| UpdateTimer(float) | Updates the timer. Must be called in the (Fixed)Update function of your MonoBehavior to work. |
| Name | Description |
|---|---|
| RemainingTime | 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. | |
| Running | If the timer is actively is counting down, meaning it was started and is not paused. |
| WaitTime | How long the timer takes to timeout. Must be greater than 0.0f. |