Documentation

Unity Engine

Download Unity

Unity Engine

Rewind(ref TimerState)

Rewinds a timer state to the start of its range.
Read time 1 minuteLast updated 4 hours ago

Definition

Rewind(TimerState)

public static void Rewind(this ref TimerState timerState)

Parameters

timerState

The timer state to rewind. The method changes this timer state.

Remarks

The method moves TimerState.PreviousTime and TimerState.Time to the start of TimerState.Range and sets TimerState.DeltaTime to zero. It doesn't change TimerState.PlayState, so a playing timer keeps playing.
When the wrap mode is WrapMode.Loop, the method also applies TimerState.CycleOffset. The time moves by the cycle offset times the duration of the range, and wraps back into the range. The method sets TimerState.PreviousLoopCount and TimerState.LoopCount to the cycle offset rounded down to a whole number. For example, with a range from
0
to
2
, a cycle offset of
1.25
sets TimerState.Time to
0.5
and both loop counts to
1
, and a cycle offset of
-0.25
sets
Time
to
1.5
and both loop counts to
-1
. With any other wrap mode, the time stays at the start of the range and the method sets both loop counts to
0
.