Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


CurveField

Make a field for editing an AnimationCurve.
Read time 12 minutesLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor

CurveField(AnimationCurve, GUILayoutOption[])

Make a field for editing an AnimationCurve.
public static AnimationCurve CurveField(AnimationCurve value, params GUILayoutOption[] options)

Parameters

The curve to edit.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

Type

Description

AnimationCurveThe curve edited by the user.

Remarks

FollowCurve (CurveField)
Create an animation on the different axis and assign it to a GameObject.
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEditor;public class FollowCurve : EditorWindow{ AnimationCurve curveX = AnimationCurve.Linear(0, 0, 10, 10); AnimationCurve curveY = AnimationCurve.Linear(0, 0, 10, 10); AnimationCurve curveZ = AnimationCurve.Linear(0, 0, 10, 10); [MenuItem("Examples/Create Curve For Object")] static void Init() { FollowCurve window = (FollowCurve)EditorWindow.GetWindow(typeof(FollowCurve)); window.Show(); } void OnGUI() { curveX = EditorGUILayout.CurveField("Animation on X", curveX); curveY = EditorGUILayout.CurveField("Animation on Y", curveY); curveZ = EditorGUILayout.CurveField("Animation on Z", curveZ); if (GUILayout.Button("Generate Curve")) AddCurveToSelectedGameObject(); } void AddCurveToSelectedGameObject() { if (Selection.activeGameObject) { FollowAnimationCurve comp = Selection.activeGameObject.AddComponent<FollowAnimationCurve>(); comp.SetCurves(curveX, curveY, curveZ); } else { Debug.LogError("No Game Object selected for adding an animation curve"); } }}
And the script that works with the example:
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(string, AnimationCurve, GUILayoutOption[])

Make a field for editing an AnimationCurve.
public static AnimationCurve CurveField(string label, AnimationCurve value, params GUILayoutOption[] options)

Parameters

label

Optional label to display in front of the field.

The curve to edit.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

Type

Description

AnimationCurveThe curve edited by the user.

Remarks

FollowCurve (CurveField)
Create an animation on the different axis and assign it to a GameObject.
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEditor;public class FollowCurve : EditorWindow{ AnimationCurve curveX = AnimationCurve.Linear(0, 0, 10, 10); AnimationCurve curveY = AnimationCurve.Linear(0, 0, 10, 10); AnimationCurve curveZ = AnimationCurve.Linear(0, 0, 10, 10); [MenuItem("Examples/Create Curve For Object")] static void Init() { FollowCurve window = (FollowCurve)EditorWindow.GetWindow(typeof(FollowCurve)); window.Show(); } void OnGUI() { curveX = EditorGUILayout.CurveField("Animation on X", curveX); curveY = EditorGUILayout.CurveField("Animation on Y", curveY); curveZ = EditorGUILayout.CurveField("Animation on Z", curveZ); if (GUILayout.Button("Generate Curve")) AddCurveToSelectedGameObject(); } void AddCurveToSelectedGameObject() { if (Selection.activeGameObject) { FollowAnimationCurve comp = Selection.activeGameObject.AddComponent<FollowAnimationCurve>(); comp.SetCurves(curveX, curveY, curveZ); } else { Debug.LogError("No Game Object selected for adding an animation curve"); } }}
And the script that works with the example:
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(GUIContent, AnimationCurve, GUILayoutOption[])

Make a field for editing an AnimationCurve.
public static AnimationCurve CurveField(GUIContent label, AnimationCurve value, params GUILayoutOption[] options)

Parameters

Optional label to display in front of the field.

The curve to edit.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

Type

Description

AnimationCurveThe curve edited by the user.

Remarks

FollowCurve (CurveField)
Create an animation on the different axis and assign it to a GameObject.
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEditor;public class FollowCurve : EditorWindow{ AnimationCurve curveX = AnimationCurve.Linear(0, 0, 10, 10); AnimationCurve curveY = AnimationCurve.Linear(0, 0, 10, 10); AnimationCurve curveZ = AnimationCurve.Linear(0, 0, 10, 10); [MenuItem("Examples/Create Curve For Object")] static void Init() { FollowCurve window = (FollowCurve)EditorWindow.GetWindow(typeof(FollowCurve)); window.Show(); } void OnGUI() { curveX = EditorGUILayout.CurveField("Animation on X", curveX); curveY = EditorGUILayout.CurveField("Animation on Y", curveY); curveZ = EditorGUILayout.CurveField("Animation on Z", curveZ); if (GUILayout.Button("Generate Curve")) AddCurveToSelectedGameObject(); } void AddCurveToSelectedGameObject() { if (Selection.activeGameObject) { FollowAnimationCurve comp = Selection.activeGameObject.AddComponent<FollowAnimationCurve>(); comp.SetCurves(curveX, curveY, curveZ); } else { Debug.LogError("No Game Object selected for adding an animation curve"); } }}
And the script that works with the example:
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(AnimationCurve, Color, Rect, GUILayoutOption[])

Make a field for editing an AnimationCurve.
public static AnimationCurve CurveField(AnimationCurve value, Color color, Rect ranges, params GUILayoutOption[] options)

Parameters

The curve to edit.

color

The color to show the curve with.

ranges

Optional rectangle that the curve is restrained within.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

Type

Description

AnimationCurveThe curve edited by the user.

Remarks

FollowCurve (CurveField)
Create an animation on the different axis and assign it to a GameObject.
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEditor;public class FollowCurve : EditorWindow{ AnimationCurve curveX = AnimationCurve.Linear(0, 0, 10, 10); AnimationCurve curveY = AnimationCurve.Linear(0, 0, 10, 10); AnimationCurve curveZ = AnimationCurve.Linear(0, 0, 10, 10); [MenuItem("Examples/Create Curve For Object")] static void Init() { FollowCurve window = (FollowCurve)EditorWindow.GetWindow(typeof(FollowCurve)); window.Show(); } void OnGUI() { curveX = EditorGUILayout.CurveField("Animation on X", curveX); curveY = EditorGUILayout.CurveField("Animation on Y", curveY); curveZ = EditorGUILayout.CurveField("Animation on Z", curveZ); if (GUILayout.Button("Generate Curve")) AddCurveToSelectedGameObject(); } void AddCurveToSelectedGameObject() { if (Selection.activeGameObject) { FollowAnimationCurve comp = Selection.activeGameObject.AddComponent<FollowAnimationCurve>(); comp.SetCurves(curveX, curveY, curveZ); } else { Debug.LogError("No Game Object selected for adding an animation curve"); } }}
And the script that works with the example:
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(string, AnimationCurve, Color, Rect, GUILayoutOption[])

Make a field for editing an AnimationCurve.
public static AnimationCurve CurveField(string label, AnimationCurve value, Color color, Rect ranges, params GUILayoutOption[] options)

Parameters

label

Optional label to display in front of the field.

The curve to edit.

color

The color to show the curve with.

ranges

Optional rectangle that the curve is restrained within.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

Type

Description

AnimationCurveThe curve edited by the user.

Remarks

FollowCurve (CurveField)
Create an animation on the different axis and assign it to a GameObject.
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEditor;public class FollowCurve : EditorWindow{ AnimationCurve curveX = AnimationCurve.Linear(0, 0, 10, 10); AnimationCurve curveY = AnimationCurve.Linear(0, 0, 10, 10); AnimationCurve curveZ = AnimationCurve.Linear(0, 0, 10, 10); [MenuItem("Examples/Create Curve For Object")] static void Init() { FollowCurve window = (FollowCurve)EditorWindow.GetWindow(typeof(FollowCurve)); window.Show(); } void OnGUI() { curveX = EditorGUILayout.CurveField("Animation on X", curveX); curveY = EditorGUILayout.CurveField("Animation on Y", curveY); curveZ = EditorGUILayout.CurveField("Animation on Z", curveZ); if (GUILayout.Button("Generate Curve")) AddCurveToSelectedGameObject(); } void AddCurveToSelectedGameObject() { if (Selection.activeGameObject) { FollowAnimationCurve comp = Selection.activeGameObject.AddComponent<FollowAnimationCurve>(); comp.SetCurves(curveX, curveY, curveZ); } else { Debug.LogError("No Game Object selected for adding an animation curve"); } }}
And the script that works with the example:
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(GUIContent, AnimationCurve, Color, Rect, GUILayoutOption[])

Make a field for editing an AnimationCurve.
public static AnimationCurve CurveField(GUIContent label, AnimationCurve value, Color color, Rect ranges, params GUILayoutOption[] options)

Parameters

Optional label to display in front of the field.

The curve to edit.

color

The color to show the curve with.

ranges

Optional rectangle that the curve is restrained within.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

Type

Description

AnimationCurveThe curve edited by the user.

Remarks

FollowCurve (CurveField)
Create an animation on the different axis and assign it to a GameObject.
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEditor;public class FollowCurve : EditorWindow{ AnimationCurve curveX = AnimationCurve.Linear(0, 0, 10, 10); AnimationCurve curveY = AnimationCurve.Linear(0, 0, 10, 10); AnimationCurve curveZ = AnimationCurve.Linear(0, 0, 10, 10); [MenuItem("Examples/Create Curve For Object")] static void Init() { FollowCurve window = (FollowCurve)EditorWindow.GetWindow(typeof(FollowCurve)); window.Show(); } void OnGUI() { curveX = EditorGUILayout.CurveField("Animation on X", curveX); curveY = EditorGUILayout.CurveField("Animation on Y", curveY); curveZ = EditorGUILayout.CurveField("Animation on Z", curveZ); if (GUILayout.Button("Generate Curve")) AddCurveToSelectedGameObject(); } void AddCurveToSelectedGameObject() { if (Selection.activeGameObject) { FollowAnimationCurve comp = Selection.activeGameObject.AddComponent<FollowAnimationCurve>(); comp.SetCurves(curveX, curveY, curveZ); } else { Debug.LogError("No Game Object selected for adding an animation curve"); } }}
And the script that works with the example:
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(SerializedProperty, Color, Rect, GUILayoutOption[])

Make a field for editing an AnimationCurve.
public static void CurveField(SerializedProperty property, Color color, Rect ranges, params GUILayoutOption[] options)

Parameters

The curve to edit.

color

The color to show the curve with.

ranges

Optional rectangle that the curve is restrained within.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

CurveField(SerializedProperty, Color, Rect, GUIContent, GUILayoutOption[])

Make a field for editing an AnimationCurve.
public static void CurveField(SerializedProperty property, Color color, Rect ranges, GUIContent label, params GUILayoutOption[] options)

Parameters

The curve to edit.

color

The color to show the curve with.

ranges

Optional rectangle that the curve is restrained within.

Optional label to display in front of the field. Pass [[GUIContent.none] to hide the label.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.