---
title: BindingUtility
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/bindingutility
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/bindingutility.md
last_updated: 2026-11-30
generated_at: 2026-11-30T20:36:57.973Z
locale: en-us
---

# BindingUtility

> Utility functions to find the index of a binding or a socket from its identifier.

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

## Remarks

Rigs and clips store the identifiers of their bindings in arrays of [StringHash](/engine/7000.0/script-reference/unity/animations/stringhash.md), and a rig stores its sockets, each with its identifier, in [RigDefinition.SocketValues](/engine/7000.0/script-reference/unity/animations/rigdefinition/socketvalues.md). Use these functions to turn an identifier into an index into one of these arrays, for example to match a binding of a clip with a binding of a rig.

The index that [BindingUtility.FindBindingIndex](/engine/7000.0/script-reference/unity/animations/bindingutility/findbindingindex.md) returns is the position in the array that you search. For a rig, that is the index among the bindings of one kind, such as [BindingSet.TranslationBindings](/engine/7000.0/script-reference/unity/animations/bindingset/translationbindings.md). To get the index among all the bindings of the rig, add the first-binding index of that kind, such as [BindingSet.TranslationBindingIndex](/engine/7000.0/script-reference/unity/animations/bindingset/translationbindingindex.md).

Both functions search the array linearly and return -1 if nothing matches.

The following example uses the `Unity.Animations` and `Unity.Entities` namespaces. It finds a float channel by its identifier, then reads and writes its value in an animation stream.

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

## Examples

```csharp
// This example finds a float channel by its identifier, then increases its value in the animation stream.
// Returns false if the rig has no float channel with that identifier.
public static bool TryIncreaseFloatChannel(
    ref AnimationStream stream,
    StringHash channelId,
    float amount,
    out float newValue)
{
    // Search the float bindings of the rig of the stream. FindBindingIndex returns -1 when there is no match.
    ref BindingSet bindings = ref stream.RigDefinition.Bindings;
    int channelIndex = BindingUtility.FindBindingIndex(ref bindings.FloatBindings, channelId);
    if (channelIndex < 0)
    {
        newValue = 0f;
        return false;
    }

    // The binding index is also the index of the float in the stream.
    newValue = stream.GetFloat(channelIndex) + amount;
    stream.SetFloat(channelIndex, newValue);
    return true;
}
```

## Static Methods

| Method                                                                                                  | Description                                                                  |
| ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [FindBindingIndex](/engine/7000.0/script-reference/unity/animations/bindingutility/findbindingindex.md) | Find a binding in a binding array.                                           |
| [FindSocketIndex](/engine/7000.0/script-reference/unity/animations/bindingutility/findsocketindex.md)   | Finds the index of the socket that matches a binding in an array of sockets. |
