# GenericBindingUtility

> Animation utility functions for reading and writing values from Unity components.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine.Animations](/engine/6000.0/script-reference/unityengine/animations.md)
* **Assembly:** UnityEngine.AnimationModule

```csharp
public static class GenericBindingUtility
```

## Examples

```csharp
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;
using UnityEditor;
using Unity.Collections;
using System.Linq;

public class AnimationClipPlayer : MonoBehaviour
{
    public AnimationClip        animationClip;
    public float                time;

    List<AnimationCurve>        curves;

    NativeArray<BoundProperty>  floatProperties;
    NativeArray<BoundProperty>  intProperties;
    NativeArray<float>          floatValues;
    NativeArray<int>            intValues;

    void Start()
    {
        var editorCurveBindings = AnimationUtility.GetCurveBindings(animationClip);
        editorCurveBindings = editorCurveBindings.Where(editorCurveBinding =>
            editorCurveBinding.type != typeof(Transform) && !editorCurveBinding.isPPtrCurve && !editorCurveBinding.isDiscreteCurve
            ).ToArray();

        curves = new List<AnimationCurve>(editorCurveBindings.Length);
        for (var i = 0; i < editorCurveBindings.Length; i++)
        {
            curves.Add(AnimationUtility.GetEditorCurve(animationClip, editorCurveBindings[i]));
        }

        var genericBindings = new NativeArray<GenericBinding>(AnimationUtility.EditorCurveBindingsToGenericBindings(editorCurveBindings), Allocator.Temp);
        GenericBindingUtility.BindProperties(gameObject, genericBindings, out floatProperties, out intProperties, Allocator.Persistent);

        floatValues = new NativeArray<float>(floatProperties.Length, Allocator.Persistent);
        intValues = new NativeArray<int>(intProperties.Length, Allocator.Persistent);
    }

    private void OnDestroy()
    {
        floatProperties.Dispose();
        floatValues.Dispose();
        intProperties.Dispose();
        intValues.Dispose();
    }

    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < curves.Count; i++)
        {
            floatValues[i] = curves[i].Evaluate(time);
        }

        GenericBindingUtility.SetValues(floatProperties, floatValues);
    }
}
```

## Static Methods

| Method                                                                                                                         | Description                                                                                                                                                                                                                       |
| ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [BindProperties](/engine/6000.0/script-reference/unityengine/animations/genericbindingutility/bindproperties.md)               | Retrieves the list of [BoundProperty](/engine/6000.0/script-reference/unityengine/animations/boundproperty.md) defined by the list of [GenericBinding](/engine/6000.0/script-reference/unityengine/animations/genericbinding.md). |
| [CreateGenericBinding](/engine/6000.0/script-reference/unityengine/animations/genericbindingutility/creategenericbinding.md)   | Retrieves the [GenericBinding](/engine/6000.0/script-reference/unityengine/animations/genericbinding.md) that represents a specific property associated with a GameObject or one of its components.                               |
| [GetAnimatableBindings](/engine/6000.0/script-reference/unityengine/animations/genericbindingutility/getanimatablebindings.md) | Retrieves the animatable bindings for a specific GameObject.                                                                                                                                                                      |
| [GetCurveBindings](/engine/6000.0/script-reference/unityengine/animations/genericbindingutility/getcurvebindings.md)           | Retrieves the curve bindings from an animation clip.                                                                                                                                                                              |
| [GetValues](/engine/6000.0/script-reference/unityengine/animations/genericbindingutility/getvalues.md)                         | Retrieves the float or integer value for each \[\[BoundProperty].                                                                                                                                                                 |
| [SetValues](/engine/6000.0/script-reference/unityengine/animations/genericbindingutility/setvalues.md)                         | Sets the float or integer value for each \[\[BoundProperty].                                                                                                                                                                      |
| [UnbindProperties](/engine/6000.0/script-reference/unityengine/animations/genericbindingutility/unbindproperties.md)           | Unbinds and frees all resources used by a list of [BoundProperty](/engine/6000.0/script-reference/unityengine/animations/boundproperty.md).                                                                                       |
