# CurveField

> Makes a field for editing an AnimationCurve.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.3/script-reference/unityeditor.md)
* **Assembly:** UnityEditor

## CurveField(Rect, AnimationCurve)

Makes a field for editing an [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md).

```csharp
public static AnimationCurve CurveField(Rect position, AnimationCurve value)
```

### Parameters

**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[AnimationCurve]\(/engine/6000.3/script-reference/unityengine/animationcurve)): The curve to edit.

### Returns

| Type                                                                            | Description                   |
| ------------------------------------------------------------------------------- | ----------------------------- |
| [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md) | The curve edited by the user. |

### Remarks

![EditorGUICurveField (CurveField)](/api/media?file=/engine/6000.3/media/images/EditorGUICurveField.png)

*Curve field in an Editor Window.*

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class EditorGUICurveField : EditorWindow
{
    AnimationCurve curveX = AnimationCurve.Linear(0, 0, 1, 0);
    AnimationCurve curveY = AnimationCurve.Linear(0, 0, 1, 1);
    AnimationCurve curveZ = AnimationCurve.Linear(0, 0, 1, 0);

    [MenuItem("Examples/Curve Field demo")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUICurveField));
        window.position = new Rect(0, 0, 400, 199);
        window.Show();
    }

    void OnGUI()
    {
        curveX = EditorGUI.CurveField(
            new Rect(3, 3, position.width - 6, 50),
            "Animation on X", curveX);
        curveY = EditorGUI.CurveField(
            new Rect(3, 56, position.width - 6, 50),
            "Animation on Y", curveY);
        curveZ = EditorGUI.CurveField(
            new Rect(3, 109, position.width - 6, 50),
            "Animation on Z", curveZ);

        if (GUI.Button(new Rect(3, 163, position.width - 6, 30), "Generate Curve"))
            AddCurveToSelectedGameObject();
    }

    // A GameObject with the FollowAnimationCurve script must be selected
    void AddCurveToSelectedGameObject()
    {
        if (Selection.activeGameObject)
        {
            FollowAnimationCurve comp  =
                Selection.activeGameObject.GetComponent<FollowAnimationCurve>();
            comp.SetCurves(curveX, curveY, curveZ);
        }
        else
        {
            Debug.LogError("No Game Object selected for adding an animation curve");
        }
    }
}
```

This is the run-time script which animates the attached GameObject:

```csharp
// Note that this must be FollowAnimationCurve.cs

using UnityEngine;
using System.Collections;

public class FollowAnimationCurve : MonoBehaviour
{
    public AnimationCurve curveX;
    public AnimationCurve curveY;
    public AnimationCurve curveZ;

    public void SetCurves(AnimationCurve xC, AnimationCurve yC, AnimationCurve zC)
    {
        curveX = xC;
        curveY = yC;
        curveZ = zC;
    }

    void Update()
    {
        transform.position = new Vector3(
            curveX.Evaluate(Time.time),
            curveY.Evaluate(Time.time),
            curveZ.Evaluate(Time.time));
    }
}
```

## CurveField(Rect, string, AnimationCurve)

Makes a field for editing an [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md).

```csharp
public static AnimationCurve CurveField(Rect position, string label, AnimationCurve value)
```

### Parameters

**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label to display in front of the field.**** (\[AnimationCurve]\(/engine/6000.3/script-reference/unityengine/animationcurve)): The curve to edit.

### Returns

| Type                                                                            | Description                   |
| ------------------------------------------------------------------------------- | ----------------------------- |
| [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md) | The curve edited by the user. |

### Remarks

![EditorGUICurveField (CurveField)](/api/media?file=/engine/6000.3/media/images/EditorGUICurveField.png)

*Curve field in an Editor Window.*

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class EditorGUICurveField : EditorWindow
{
    AnimationCurve curveX = AnimationCurve.Linear(0, 0, 1, 0);
    AnimationCurve curveY = AnimationCurve.Linear(0, 0, 1, 1);
    AnimationCurve curveZ = AnimationCurve.Linear(0, 0, 1, 0);

    [MenuItem("Examples/Curve Field demo")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUICurveField));
        window.position = new Rect(0, 0, 400, 199);
        window.Show();
    }

    void OnGUI()
    {
        curveX = EditorGUI.CurveField(
            new Rect(3, 3, position.width - 6, 50),
            "Animation on X", curveX);
        curveY = EditorGUI.CurveField(
            new Rect(3, 56, position.width - 6, 50),
            "Animation on Y", curveY);
        curveZ = EditorGUI.CurveField(
            new Rect(3, 109, position.width - 6, 50),
            "Animation on Z", curveZ);

        if (GUI.Button(new Rect(3, 163, position.width - 6, 30), "Generate Curve"))
            AddCurveToSelectedGameObject();
    }

    // A GameObject with the FollowAnimationCurve script must be selected
    void AddCurveToSelectedGameObject()
    {
        if (Selection.activeGameObject)
        {
            FollowAnimationCurve comp  =
                Selection.activeGameObject.GetComponent<FollowAnimationCurve>();
            comp.SetCurves(curveX, curveY, curveZ);
        }
        else
        {
            Debug.LogError("No Game Object selected for adding an animation curve");
        }
    }
}
```

This is the run-time script which animates the attached GameObject:

```csharp
// Note that this must be FollowAnimationCurve.cs

using UnityEngine;
using System.Collections;

public class FollowAnimationCurve : MonoBehaviour
{
    public AnimationCurve curveX;
    public AnimationCurve curveY;
    public AnimationCurve curveZ;

    public void SetCurves(AnimationCurve xC, AnimationCurve yC, AnimationCurve zC)
    {
        curveX = xC;
        curveY = yC;
        curveZ = zC;
    }

    void Update()
    {
        transform.position = new Vector3(
            curveX.Evaluate(Time.time),
            curveY.Evaluate(Time.time),
            curveZ.Evaluate(Time.time));
    }
}
```

## CurveField(Rect, GUIContent, AnimationCurve)

Makes a field for editing an [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md).

```csharp
public static AnimationCurve CurveField(Rect position, GUIContent label, AnimationCurve value)
```

### Parameters

**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[GUIContent]\(/engine/6000.3/script-reference/unityengine/guicontent)): Optional label to display in front of the field.**** (\[AnimationCurve]\(/engine/6000.3/script-reference/unityengine/animationcurve)): The curve to edit.

### Returns

| Type                                                                            | Description                   |
| ------------------------------------------------------------------------------- | ----------------------------- |
| [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md) | The curve edited by the user. |

### Remarks

![EditorGUICurveField (CurveField)](/api/media?file=/engine/6000.3/media/images/EditorGUICurveField.png)

*Curve field in an Editor Window.*

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class EditorGUICurveField : EditorWindow
{
    AnimationCurve curveX = AnimationCurve.Linear(0, 0, 1, 0);
    AnimationCurve curveY = AnimationCurve.Linear(0, 0, 1, 1);
    AnimationCurve curveZ = AnimationCurve.Linear(0, 0, 1, 0);

    [MenuItem("Examples/Curve Field demo")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUICurveField));
        window.position = new Rect(0, 0, 400, 199);
        window.Show();
    }

    void OnGUI()
    {
        curveX = EditorGUI.CurveField(
            new Rect(3, 3, position.width - 6, 50),
            "Animation on X", curveX);
        curveY = EditorGUI.CurveField(
            new Rect(3, 56, position.width - 6, 50),
            "Animation on Y", curveY);
        curveZ = EditorGUI.CurveField(
            new Rect(3, 109, position.width - 6, 50),
            "Animation on Z", curveZ);

        if (GUI.Button(new Rect(3, 163, position.width - 6, 30), "Generate Curve"))
            AddCurveToSelectedGameObject();
    }

    // A GameObject with the FollowAnimationCurve script must be selected
    void AddCurveToSelectedGameObject()
    {
        if (Selection.activeGameObject)
        {
            FollowAnimationCurve comp  =
                Selection.activeGameObject.GetComponent<FollowAnimationCurve>();
            comp.SetCurves(curveX, curveY, curveZ);
        }
        else
        {
            Debug.LogError("No Game Object selected for adding an animation curve");
        }
    }
}
```

This is the run-time script which animates the attached GameObject:

```csharp
// Note that this must be FollowAnimationCurve.cs

using UnityEngine;
using System.Collections;

public class FollowAnimationCurve : MonoBehaviour
{
    public AnimationCurve curveX;
    public AnimationCurve curveY;
    public AnimationCurve curveZ;

    public void SetCurves(AnimationCurve xC, AnimationCurve yC, AnimationCurve zC)
    {
        curveX = xC;
        curveY = yC;
        curveZ = zC;
    }

    void Update()
    {
        transform.position = new Vector3(
            curveX.Evaluate(Time.time),
            curveY.Evaluate(Time.time),
            curveZ.Evaluate(Time.time));
    }
}
```

## CurveField(Rect, AnimationCurve, Color, Rect)

Makes a field for editing an [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md).

```csharp
public static AnimationCurve CurveField(Rect position, AnimationCurve value, Color color, Rect ranges)
```

### Parameters

**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[AnimationCurve]\(/engine/6000.3/script-reference/unityengine/animationcurve)): The curve to edit.**** (\[Color]\(/engine/6000.3/script-reference/unityengine/color)): The color to show the curve with.**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Optional rectangle that the curve is restrained within.

### Returns

| Type                                                                            | Description                   |
| ------------------------------------------------------------------------------- | ----------------------------- |
| [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md) | The curve edited by the user. |

### Remarks

![EditorGUICurveField (CurveField)](/api/media?file=/engine/6000.3/media/images/EditorGUICurveField.png)

*Curve field in an Editor Window.*

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class EditorGUICurveField : EditorWindow
{
    AnimationCurve curveX = AnimationCurve.Linear(0, 0, 1, 0);
    AnimationCurve curveY = AnimationCurve.Linear(0, 0, 1, 1);
    AnimationCurve curveZ = AnimationCurve.Linear(0, 0, 1, 0);

    [MenuItem("Examples/Curve Field demo")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUICurveField));
        window.position = new Rect(0, 0, 400, 199);
        window.Show();
    }

    void OnGUI()
    {
        curveX = EditorGUI.CurveField(
            new Rect(3, 3, position.width - 6, 50),
            "Animation on X", curveX);
        curveY = EditorGUI.CurveField(
            new Rect(3, 56, position.width - 6, 50),
            "Animation on Y", curveY);
        curveZ = EditorGUI.CurveField(
            new Rect(3, 109, position.width - 6, 50),
            "Animation on Z", curveZ);

        if (GUI.Button(new Rect(3, 163, position.width - 6, 30), "Generate Curve"))
            AddCurveToSelectedGameObject();
    }

    // A GameObject with the FollowAnimationCurve script must be selected
    void AddCurveToSelectedGameObject()
    {
        if (Selection.activeGameObject)
        {
            FollowAnimationCurve comp  =
                Selection.activeGameObject.GetComponent<FollowAnimationCurve>();
            comp.SetCurves(curveX, curveY, curveZ);
        }
        else
        {
            Debug.LogError("No Game Object selected for adding an animation curve");
        }
    }
}
```

This is the run-time script which animates the attached GameObject:

```csharp
// Note that this must be FollowAnimationCurve.cs

using UnityEngine;
using System.Collections;

public class FollowAnimationCurve : MonoBehaviour
{
    public AnimationCurve curveX;
    public AnimationCurve curveY;
    public AnimationCurve curveZ;

    public void SetCurves(AnimationCurve xC, AnimationCurve yC, AnimationCurve zC)
    {
        curveX = xC;
        curveY = yC;
        curveZ = zC;
    }

    void Update()
    {
        transform.position = new Vector3(
            curveX.Evaluate(Time.time),
            curveY.Evaluate(Time.time),
            curveZ.Evaluate(Time.time));
    }
}
```

## CurveField(Rect, string, AnimationCurve, Color, Rect)

Makes a field for editing an [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md).

```csharp
public static AnimationCurve CurveField(Rect position, string label, AnimationCurve value, Color color, Rect ranges)
```

### Parameters

**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label to display in front of the field.**** (\[AnimationCurve]\(/engine/6000.3/script-reference/unityengine/animationcurve)): The curve to edit.**** (\[Color]\(/engine/6000.3/script-reference/unityengine/color)): The color to show the curve with.**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Optional rectangle that the curve is restrained within.

### Returns

| Type                                                                            | Description                   |
| ------------------------------------------------------------------------------- | ----------------------------- |
| [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md) | The curve edited by the user. |

### Remarks

![EditorGUICurveField (CurveField)](/api/media?file=/engine/6000.3/media/images/EditorGUICurveField.png)

*Curve field in an Editor Window.*

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class EditorGUICurveField : EditorWindow
{
    AnimationCurve curveX = AnimationCurve.Linear(0, 0, 1, 0);
    AnimationCurve curveY = AnimationCurve.Linear(0, 0, 1, 1);
    AnimationCurve curveZ = AnimationCurve.Linear(0, 0, 1, 0);

    [MenuItem("Examples/Curve Field demo")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUICurveField));
        window.position = new Rect(0, 0, 400, 199);
        window.Show();
    }

    void OnGUI()
    {
        curveX = EditorGUI.CurveField(
            new Rect(3, 3, position.width - 6, 50),
            "Animation on X", curveX);
        curveY = EditorGUI.CurveField(
            new Rect(3, 56, position.width - 6, 50),
            "Animation on Y", curveY);
        curveZ = EditorGUI.CurveField(
            new Rect(3, 109, position.width - 6, 50),
            "Animation on Z", curveZ);

        if (GUI.Button(new Rect(3, 163, position.width - 6, 30), "Generate Curve"))
            AddCurveToSelectedGameObject();
    }

    // A GameObject with the FollowAnimationCurve script must be selected
    void AddCurveToSelectedGameObject()
    {
        if (Selection.activeGameObject)
        {
            FollowAnimationCurve comp  =
                Selection.activeGameObject.GetComponent<FollowAnimationCurve>();
            comp.SetCurves(curveX, curveY, curveZ);
        }
        else
        {
            Debug.LogError("No Game Object selected for adding an animation curve");
        }
    }
}
```

This is the run-time script which animates the attached GameObject:

```csharp
// Note that this must be FollowAnimationCurve.cs

using UnityEngine;
using System.Collections;

public class FollowAnimationCurve : MonoBehaviour
{
    public AnimationCurve curveX;
    public AnimationCurve curveY;
    public AnimationCurve curveZ;

    public void SetCurves(AnimationCurve xC, AnimationCurve yC, AnimationCurve zC)
    {
        curveX = xC;
        curveY = yC;
        curveZ = zC;
    }

    void Update()
    {
        transform.position = new Vector3(
            curveX.Evaluate(Time.time),
            curveY.Evaluate(Time.time),
            curveZ.Evaluate(Time.time));
    }
}
```

## CurveField(Rect, GUIContent, AnimationCurve, Color, Rect)

Makes a field for editing an [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md).

```csharp
public static AnimationCurve CurveField(Rect position, GUIContent label, AnimationCurve value, Color color, Rect ranges)
```

### Parameters

**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[GUIContent]\(/engine/6000.3/script-reference/unityengine/guicontent)): Optional label to display in front of the field.**** (\[AnimationCurve]\(/engine/6000.3/script-reference/unityengine/animationcurve)): The curve to edit.**** (\[Color]\(/engine/6000.3/script-reference/unityengine/color)): The color to show the curve with.**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Optional rectangle that the curve is restrained within.

### Returns

| Type                                                                            | Description                   |
| ------------------------------------------------------------------------------- | ----------------------------- |
| [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md) | The curve edited by the user. |

### Remarks

![EditorGUICurveField (CurveField)](/api/media?file=/engine/6000.3/media/images/EditorGUICurveField.png)

*Curve field in an Editor Window.*

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class EditorGUICurveField : EditorWindow
{
    AnimationCurve curveX = AnimationCurve.Linear(0, 0, 1, 0);
    AnimationCurve curveY = AnimationCurve.Linear(0, 0, 1, 1);
    AnimationCurve curveZ = AnimationCurve.Linear(0, 0, 1, 0);

    [MenuItem("Examples/Curve Field demo")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUICurveField));
        window.position = new Rect(0, 0, 400, 199);
        window.Show();
    }

    void OnGUI()
    {
        curveX = EditorGUI.CurveField(
            new Rect(3, 3, position.width - 6, 50),
            "Animation on X", curveX);
        curveY = EditorGUI.CurveField(
            new Rect(3, 56, position.width - 6, 50),
            "Animation on Y", curveY);
        curveZ = EditorGUI.CurveField(
            new Rect(3, 109, position.width - 6, 50),
            "Animation on Z", curveZ);

        if (GUI.Button(new Rect(3, 163, position.width - 6, 30), "Generate Curve"))
            AddCurveToSelectedGameObject();
    }

    // A GameObject with the FollowAnimationCurve script must be selected
    void AddCurveToSelectedGameObject()
    {
        if (Selection.activeGameObject)
        {
            FollowAnimationCurve comp  =
                Selection.activeGameObject.GetComponent<FollowAnimationCurve>();
            comp.SetCurves(curveX, curveY, curveZ);
        }
        else
        {
            Debug.LogError("No Game Object selected for adding an animation curve");
        }
    }
}
```

This is the run-time script which animates the attached GameObject:

```csharp
// Note that this must be FollowAnimationCurve.cs

using UnityEngine;
using System.Collections;

public class FollowAnimationCurve : MonoBehaviour
{
    public AnimationCurve curveX;
    public AnimationCurve curveY;
    public AnimationCurve curveZ;

    public void SetCurves(AnimationCurve xC, AnimationCurve yC, AnimationCurve zC)
    {
        curveX = xC;
        curveY = yC;
        curveZ = zC;
    }

    void Update()
    {
        transform.position = new Vector3(
            curveX.Evaluate(Time.time),
            curveY.Evaluate(Time.time),
            curveZ.Evaluate(Time.time));
    }
}
```

## CurveField(Rect, SerializedProperty, Color, Rect)

Makes a field for editing an [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md).

```csharp
public static void CurveField(Rect position, SerializedProperty property, Color color, Rect ranges)
```

### Parameters

**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[SerializedProperty]\(/engine/6000.3/script-reference/unityeditor/serializedproperty)): The curve to edit.**** (\[Color]\(/engine/6000.3/script-reference/unityengine/color)): The color to show the curve with.**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Optional rectangle that the curve is restrained within.

## CurveField(Rect, SerializedProperty, Color, Rect, GUIContent)

Makes a field for editing an [AnimationCurve](/engine/6000.3/script-reference/unityengine/animationcurve.md).

```csharp
public static void CurveField(Rect position, SerializedProperty property, Color color, Rect ranges, GUIContent label)
```

### Parameters

**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[SerializedProperty]\(/engine/6000.3/script-reference/unityeditor/serializedproperty)): The curve to edit.**** (\[Color]\(/engine/6000.3/script-reference/unityengine/color)): The color to show the curve with.**** (\[Rect]\(/engine/6000.3/script-reference/unityengine/rect)): Optional rectangle that the curve is restrained within.**** (\[GUIContent]\(/engine/6000.3/script-reference/unityengine/guicontent)): Optional label to display in front of the field. Pass \[\[GUIContent.none] to hide the label.
