---
title: ToClipSampler(AnimationClip, ref RigDefinition, Allocator)
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/animationclipextensions/toclipsampler
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/animationclipextensions/toclipsampler.md
last_updated: 2026-11-30
generated_at: 2026-11-30T21:48:46.248Z
locale: en-us
---

# ToClipSampler(AnimationClip, ref RigDefinition, Allocator)

> Creates a ClipSampler that samples an animation clip for a rig.

## Definition

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

## ToClipSampler(AnimationClip, RigDefinition, Allocator)

```csharp
public static ClipSampler ToClipSampler(this AnimationClip clip, ref RigDefinition rig, Allocator allocator)
```

### Parameters

**** (\[AnimationClip]\(/engine/7000.0/script-reference/unityengine/animationclip)): The animation clip to sample. Can be null.**** (\[RigDefinition]\(/engine/7000.0/script-reference/unity/animations/rigdefinition)): The rig of the animation streams to sample into. The sampler samples only the channels of the clip that the rig has.**** (\[Allocator]\(/engine/7000.0/script-reference/unity/collections/allocator)): The allocator to use for the memory of the sampler. Use a valid allocator. [Allocator.Invalid](/engine/7000.0/script-reference/unity/collections/allocator/invalid.md) and [Allocator.None](/engine/7000.0/script-reference/unity/collections/allocator/none.md) aren't allowed.

### Returns

| Type                                                                           | Description                                                                                                                                                                                                                                                                                           |
| ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [ClipSampler](/engine/7000.0/script-reference/unity/animations/clipsampler.md) | The new sampler. Dispose it when you finish with it. [ClipSampler.IsCreated](/engine/7000.0/script-reference/unity/animations/clipsampler/iscreated.md) is `false` if `clip` is `null`, is a Humanoid clip, has no data, or stores data with another layout version, or if `rig` is a null reference. |

### Remarks

Call this method from the main thread. The sampler acquires its own reference to the clip data. It keeps sampling that data even if the animation clip is destroyed, edited, or its data is replaced. To sample the edited clip, create the sampler again.

This method is expensive. It matches every curve of the clip with the channels of the rig, and the time it takes grows with the number of curves times the number of channels. Create one sampler for each pair of clip and rig, for example when your content loads, and keep it. When you need more samplers for the same clip and rig, for example one for each character, call [ClipSampler.Clone](/engine/7000.0/script-reference/unity/animations/clipsampler/clone.md) on the sampler you kept. A clone only copies memory.

Dispose the sampler when you finish with it.

Only Generic clips are supported. If `clip` is a Humanoid clip, this method logs a warning once for the clip and returns a sampler that isn't created.
