# EditorCurveBinding

> Identifies an animatable property on a Component or GameObject.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEditor](/engine/6000.7/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule
* **Implements:** [IEquatable\<EditorCurveBinding>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public struct EditorCurveBinding : IEquatable<EditorCurveBinding>
```

## Remarks

The [AnimationWindow](/engine/6000.7/script-reference/unityeditor/animationwindow.md) uses editor curve binding to identify animation properties. This makes clip authoring possible.

You can use this binding to get, set or replace a curve in an [AnimationClip](/engine/6000.7/script-reference/unityengine/animationclip.md) when clip authoring. To do this, use the [AnimationUtility.GetCurveBindings](/engine/6000.7/script-reference/unityeditor/animationutility/getcurvebindings.md) and [AnimationUtility.GetObjectReferenceCurveBindings](/engine/6000.7/script-reference/unityeditor/animationutility/getobjectreferencecurvebindings.md) methods to retrieve the array of the animated bindings for an [AnimationClip](/engine/6000.7/script-reference/unityengine/animationclip.md). For a single property, use  [AnimationUtility.GetEditorCurve](/engine/6000.7/script-reference/unityeditor/animationutility/geteditorcurve.md) or [AnimationUtility.GetObjectReferenceCurve](/engine/6000.7/script-reference/unityeditor/animationutility/getobjectreferencecurve.md) to retrieve the curve identified by the editor curve binding of an [AnimationClip](/engine/6000.7/script-reference/unityengine/animationclip.md). Use the [AnimationUtility.SetEditorCurve](/engine/6000.7/script-reference/unityeditor/animationutility/seteditorcurve.md) or [AnimationUtility.SetObjectReferenceCurve](/engine/6000.7/script-reference/unityeditor/animationutility/setobjectreferencecurve.md) to set the curve. When recording live animation with the [GameObjectRecorder](/engine/6000.7/script-reference/unityeditor/animations/gameobjectrecorder.md), use the [GameObjectRecorder.Bind](/engine/6000.7/script-reference/unityeditor/animations/gameobjectrecorder/bind.md) method to bind a GameObject property identified by an editor curve binding.

Additional Resources: [AnimationUtility](/engine/6000.7/script-reference/unityeditor/animationutility.md) [GameObjectRecorder](/engine/6000.7/script-reference/unityeditor/animations/gameobjectrecorder.md).

## Examples

```csharp
using UnityEditor;
using UnityEngine;

public static class EditorCurveBindingExample
{
    // Change these values to match the prefix you want to remove and add.
    // For example, properties with paths "", "Hips", "Hips/LeftLeg",
    // are moved to "Root", "Root/Hips", "Root/Hips/LeftLeg".
    private const string k_PrefixToRemove = "";
    private const string k_PrefixToAdd = "Root";

    // This example moves the animated properties parented to `prefixToRemove` to
    // new properties parented to `prefixToAdd` on a selected animation clip.
    [MenuItem("Example/Reparent Animated Properties On Selected Animation Clip")]
    static void ReparentAnimatedPropertiesOnSelectedAnimationClip()
    {
        var clip = Selection.activeObject as AnimationClip;
        if (clip == null)
        {
            Debug.LogError("No animation clip selected.");
            return;
        }

        var clipBindings = AnimationUtility.GetCurveBindings(clip);

        foreach (var binding in clipBindings)
        {
            if (binding.path.StartsWith(k_PrefixToRemove))
            {
                var newBinding = binding;
                newBinding.path = binding.path.Substring(k_PrefixToRemove.Length);
                if (newBinding.path.StartsWith('/'))
                    newBinding.path = newBinding.path.Substring(1);

                if (string.IsNullOrEmpty(newBinding.path))
                    newBinding.path = k_PrefixToAdd;
                else if (!string.IsNullOrEmpty(k_PrefixToAdd))
                    newBinding.path = k_PrefixToAdd + "/" + newBinding.path;

                var curve = AnimationUtility.GetEditorCurve(clip, binding);

                // You rename curves by removing the old curve and adding a new one
                // with a new binding. You can also use the
                // AnimationUtility.SetEditorCurves method to set multiple curves at once.
                AnimationUtility.SetEditorCurve(clip, binding, null);
                AnimationUtility.SetEditorCurve(clip, newBinding, curve);
            }
        }

        AssetDatabase.SaveAssetIfDirty(clip);
    }
}
```

## Fields

| Value                                                                                          | Description                                        |
| ---------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| [path](/engine/6000.7/script-reference/unityeditor/editorcurvebinding/path.md)                 | The transform path of the object that is animated. |
| [propertyName](/engine/6000.7/script-reference/unityeditor/editorcurvebinding/propertyname.md) | The name of the property to be animated.           |

## Properties

| Property                                                                                                                 | Description                                                                                                                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [isDiscreteCurve](/engine/6000.7/script-reference/unityeditor/editorcurvebinding/isdiscretecurve.md)                     | Returns true if the binding is a discrete curve. Returns false otherwise. (Read Only)                                                                                                                      |
| [isPPtrCurve](/engine/6000.7/script-reference/unityeditor/editorcurvebinding/ispptrcurve.md)                             | Returns true if the binding is an object curve. Returns false otherwise (Read Only)                                                                                                                        |
| [isSerializeReferenceCurve](/engine/6000.7/script-reference/unityeditor/editorcurvebinding/isserializereferencecurve.md) | Returns true if the binding is to a curve that points to field on a [SerializeReference](/engine/6000.7/script-reference/unityengine/serializereference.md) instance. Returns false otherwise. (Read Only) |
| [type](/engine/6000.7/script-reference/unityeditor/editorcurvebinding/type.md)                                           | The type of the property to be animated.                                                                                                                                                                   |

## Static Methods

| Method                                                                                                               | Description                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [DiscreteCurve](/engine/6000.7/script-reference/unityeditor/editorcurvebinding/discretecurve.md)                     | Creates a preconfigured binding for a curve where values should not be interpolated.                                                                                 |
| [FloatCurve](/engine/6000.7/script-reference/unityeditor/editorcurvebinding/floatcurve.md)                           | Creates a preconfigured binding for a float curve.                                                                                                                   |
| [PPtrCurve](/engine/6000.7/script-reference/unityeditor/editorcurvebinding/pptrcurve.md)                             | Creates a preconfigured binding for a curve that points to an [Object](/engine/6000.7/script-reference/unityengine/object.md).                                       |
| [SerializeReferenceCurve](/engine/6000.7/script-reference/unityeditor/editorcurvebinding/serializereferencecurve.md) | Creates a preconfigured binding for a curve that points to a [SerializeReference](/engine/6000.7/script-reference/unityengine/serializereference.md) instance field. |
