---
title: AnimationEventUtility
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/animationeventutility
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/animationeventutility.md
last_updated: 2026-11-30
generated_at: 2026-11-30T21:11:48.053Z
locale: en-us
---

# AnimationEventUtility

> Functions to read the animation events baked into a clip.

## 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 AnimationEventUtility
```

## Remarks

The clip data stores the time, the function name, and the parameters of each animation event of the source animation clip. Use [AnimationEventUtility.GatherAnimationEvents](/engine/7000.0/script-reference/unity/animations/animationeventutility/gatheranimationevents.md) to read the events that a clip timer crossed during a frame. The timer is the one that you pass to [ClipSampler.Sample](/engine/7000.0/script-reference/unity/animations/clipsampler/sample.md), so the events match the sampled pose.

The following example uses the `System.Collections.Generic`, `Unity.Animations`, `Unity.Collections`, `Unity.Entities`, `Unity.IntegerTime`, and `UnityEngine` namespaces. It gathers the animation events that the playback time of a clip passes between two updates. The range can span several loops of a looping clip.

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

## Examples

```csharp
// This example reads the function name of each animation event that the clip time
// crosses between two updates.
public static List<string> GatherEventFunctionNames(
    AnimationClip animationClip, float previousTime, float currentTime)
{
    using BlobObjectReference<Clip> clipReference = animationClip.ToClipReference();
    // Stop if the animation clip is null or has no clip data.
    if (!clipReference.IsValid)
    {
        return new List<string>();
    }

    AnimationEvent[] clipEvents = animationClip.events;

    // Gather the events from previousTime (excluded) to currentTime (included), in seconds from the start of the clip.
    // To step over the end of a looping clip, pass a currentTime that is greater than the length of the clip.
    // When previousTime is greater than currentTime, the clip plays backward and the events come in descending order.
    using NativeList<GatheredAnimationEvent> gatheredEvents =
        new NativeList<GatheredAnimationEvent>(Allocator.Temp);
    AnimationEventUtility.GatherAnimationEvents(
        ref clipReference.Value, new DiscreteTime(previousTime), new DiscreteTime(currentTime), gatheredEvents);

    // The event index of each gathered event is its index in AnimationClip.events.
    List<string> functionNames = new List<string>();
    foreach (GatheredAnimationEvent gatheredEvent in gatheredEvents)
    {
        AnimationEvent clipEvent = clipEvents[gatheredEvent.EventIndex];
        functionNames.Add(clipEvent.functionName);
    }

    // For events at 0.25 and 0.75 seconds in a looping clip of 1 second, a range from 0.6 to 1.3 returns
    // the 0.75 event, then the 0.25 event of the next loop.
    return functionNames;
}
```

## Static Methods

| Method                                                                                                                   | Description                                                                         |
| ------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- |
| [GatherAnimationEvents](/engine/7000.0/script-reference/unity/animations/animationeventutility/gatheranimationevents.md) | Appends the animation events that a timer crossed during its last update to a list. |
