---
title: TimerStateExtensions
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/timerstateextensions
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/timerstateextensions.md
last_updated: 2026-11-30
generated_at: 2026-11-30T20:42:38.771Z
locale: en-us
---

# TimerStateExtensions

> Extension methods for TimerState to control playback.

## Definition

* **Type:** Class
* **Namespace:** [Unity.Animations](/engine/7000.0/script-reference/unity/animations.md)
* **Assembly:** [UnityEngine.AnimationCoreModule](/engine/7000.0/script-reference/modules/unityengine-animationcoremodule.md)

```csharp
public static class TimerStateExtensions
```

## Remarks

Call [TimerStateExtensions.Play](/engine/7000.0/script-reference/unity/animations/timerstateextensions/play.md) to start a timer, and call [TimerStateExtensions.Update](/engine/7000.0/script-reference/unity/animations/timerstateextensions/update.md) once per frame to advance it. A timer advances only while it's playing. The methods modify the timer, so call them on a variable, not on a readonly field or an `in` parameter.

To move a timer to another time without playing through the time in between, use one of these methods:

* [TimerStateExtensions.JumpToTime](/engine/7000.0/script-reference/unity/animations/timerstateextensions/jumptotime.md) sets the timer to a time that you choose. The time you skip doesn't count as played.

* [TimerStateExtensions.Rewind](/engine/7000.0/script-reference/unity/animations/timerstateextensions/rewind.md) sets the timer to the start of its range, without changing whether the timer is playing.

If the timer advances in the next `Update` after either method, [AnimationEventUtility.GatherAnimationEvents](/engine/7000.0/script-reference/unity/animations/animationeventutility/gatheranimationevents.md) includes the animation events at the new time. Both methods apply the [TimerState.CycleOffset](/engine/7000.0/script-reference/unity/animations/timerstate/cycleoffset.md) only when the wrap mode of the timer is [WrapMode.Loop](/engine/7000.0/script-reference/unityengine/wrapmode/loop.md).

The following example uses the `Unity.Animations`, `Unity.Entities`, `Unity.IntegerTime`, and `UnityEngine` namespaces. It creates a timer for a clip with [Clip.ToTimerState](/engine/7000.0/script-reference/unity/animations/clip/totimerstate.md) and updates it once per frame.

Additional Resources: [TimerState](/engine/7000.0/script-reference/unity/animations/timerstate.md)

## Examples

```csharp
// This example plays a clip for a number of frames and returns the state of the timer after the last frame.
public static TimerState PlayClip(AnimationClip animationClip, float deltaTime, int frameCount)
{
    using BlobObjectReference<Clip> clipReference = animationClip.ToClipReference();
    ref Clip clip = ref clipReference.Value;

    // Create a playing timer that takes its range, wrap mode, and cycle offset from the clip.
    TimerState timerState = clip.ToTimerState(DiscreteTime.Zero);

    // Update the timer once per frame. In a real application, pass the frame delta time.
    for (int frame = 0; frame < frameCount; ++frame)
    {
        timerState.Update(new DiscreteTime(deltaTime));
    }

    // For a one-second clip with Loop Time enabled, three updates of 0.4 seconds
    // leave the timer at 0.2 seconds, with a loop count of 1.
    // Without Loop Time, the timer stays at the end of the clip, at 1 second.
    return timerState;
}
```

## Static Methods

| Method                                                                                            | Description                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [JumpToTime](/engine/7000.0/script-reference/unity/animations/timerstateextensions/jumptotime.md) | Jumps a timer state to a specific time, without advancing the timer from the current time to that time.                                                                                                                                                                                                                                                                                                                                 |
| [Pause](/engine/7000.0/script-reference/unity/animations/timerstateextensions/pause.md)           | Pauses a [TimerState](/engine/7000.0/script-reference/unity/animations/timerstate.md), so that it doesn't advance during following updates of the [TimerState](/engine/7000.0/script-reference/unity/animations/timerstate.md). The behavior of a [TimerState](/engine/7000.0/script-reference/unity/animations/timerstate.md) when paused is the same as stopped, the only difference is how other systems interpret those two states. |
| [Play](/engine/7000.0/script-reference/unity/animations/timerstateextensions/play.md)             | Starts playing a [TimerState](/engine/7000.0/script-reference/unity/animations/timerstate.md), so that it advances during all following updates of the [TimerState](/engine/7000.0/script-reference/unity/animations/timerstate.md).                                                                                                                                                                                                    |
| [Rewind](/engine/7000.0/script-reference/unity/animations/timerstateextensions/rewind.md)         | Rewinds a timer state to the start of its range.                                                                                                                                                                                                                                                                                                                                                                                        |
| [Stop](/engine/7000.0/script-reference/unity/animations/timerstateextensions/stop.md)             | Stops a [TimerState](/engine/7000.0/script-reference/unity/animations/timerstate.md), so that it doesn't advance during following updates of the [TimerState](/engine/7000.0/script-reference/unity/animations/timerstate.md). The behavior of a [TimerState](/engine/7000.0/script-reference/unity/animations/timerstate.md) when stopped is the same as paused, the only difference is how other systems interpret those two states.  |
| [Update](/engine/7000.0/script-reference/unity/animations/timerstateextensions/update.md)         | Advances a timer by a time step and applies its wrap mode.                                                                                                                                                                                                                                                                                                                                                                              |
