docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class CurveEditor

    An editable animation-curve graph: drag keys, drag the selected key's tangent handles, double-click to add a key, and pick a preset.

    Inheritance
    object
    CallbackEventHandler
    Focusable
    VisualElement
    CurveEditor
    Implements
    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    INotifyValueChanged<AnimationCurve>
    ICustomAnimationCurveFieldPicker
    Inherited Members
    VisualElement.disabledUssClassName
    VisualElement.SetActivePseudoState(bool)
    VisualElement.SetCheckedPseudoState(bool)
    VisualElement.Focus()
    VisualElement.SendEvent(EventBase)
    VisualElement.SetEnabledFromHierarchy(bool)
    VisualElement.SetEnabled(bool)
    VisualElement.MarkDirtyRepaint()
    VisualElement.IsMarkedForRepaint()
    VisualElement.ContainsPoint(Vector2)
    VisualElement.Overlaps(Rect)
    VisualElement.DoMeasure(float, VisualElement.MeasureMode, float, VisualElement.MeasureMode)
    VisualElement.ToString()
    VisualElement.GetClasses()
    VisualElement.ClearClassList()
    VisualElement.AddToClassList(string)
    VisualElement.RemoveFromClassList(string)
    VisualElement.ToggleInClassList(string)
    VisualElement.EnableInClassList(string, bool)
    VisualElement.ClassListContains(string)
    VisualElement.FindAncestorUserData()
    VisualElement.SetBinding(BindingId, Binding)
    VisualElement.GetBinding(BindingId)
    VisualElement.TryGetBinding(BindingId, out Binding)
    VisualElement.GetBindingInfos()
    VisualElement.GetBindingInfos(List<BindingInfo>)
    VisualElement.HasBinding(BindingId)
    VisualElement.ClearBinding(BindingId)
    VisualElement.ClearBindings()
    VisualElement.GetHierarchicalDataSourceContext()
    VisualElement.GetDataSourceContext(BindingId)
    VisualElement.TryGetDataSourceContext(BindingId, out DataSourceContext)
    VisualElement.TryGetLastBindingToUIResult(in BindingId, out BindingResult)
    VisualElement.TryGetLastBindingToSourceResult(in BindingId, out BindingResult)
    VisualElement.Add(VisualElement)
    VisualElement.Insert(int, VisualElement)
    VisualElement.Remove(VisualElement)
    VisualElement.RemoveAt(int)
    VisualElement.Clear()
    VisualElement.ElementAt(int)
    VisualElement.IndexOf(VisualElement)
    VisualElement.Children()
    VisualElement.Sort(Comparison<VisualElement>)
    VisualElement.BringToFront()
    VisualElement.SendToBack()
    VisualElement.PlaceBehind(VisualElement)
    VisualElement.PlaceInFront(VisualElement)
    VisualElement.RemoveFromHierarchy()
    VisualElement.GetFirstOfType<T>()
    VisualElement.GetFirstAncestorOfType<T>()
    VisualElement.Contains(VisualElement)
    VisualElement.FindCommonAncestor(VisualElement)
    VisualElement.viewDataKey
    VisualElement.userData
    VisualElement.canGrabFocus
    VisualElement.focusController
    VisualElement.disablePlayModeTint
    VisualElement.usageHints
    VisualElement.transform
    VisualElement.scaledPixelsPerPoint
    VisualElement.layout
    VisualElement.contentRect
    VisualElement.paddingRect
    VisualElement.worldBound
    VisualElement.localBound
    VisualElement.worldTransform
    VisualElement.hasActivePseudoState
    VisualElement.hasInactivePseudoState
    VisualElement.hasHoverPseudoState
    VisualElement.hasCheckedPseudoState
    VisualElement.hasEnabledPseudoState
    VisualElement.hasDisabledPseudoState
    VisualElement.hasFocusPseudoState
    VisualElement.hasRootPseudoState
    VisualElement.pickingMode
    VisualElement.name
    VisualElement.enabledInHierarchy
    VisualElement.enabledSelf
    VisualElement.languageDirection
    VisualElement.visible
    VisualElement.generateVisualContent
    VisualElement.dataSource
    VisualElement.dataSourcePath
    VisualElement.dataSourceType
    VisualElement.experimental
    VisualElement.hierarchy
    VisualElement.cacheAsBitmap
    VisualElement.parent
    VisualElement.panel
    VisualElement.visualTreeAssetSource
    VisualElement.this[int]
    VisualElement.childCount
    VisualElement.schedule
    VisualElement.style
    VisualElement.resolvedStyle
    VisualElement.customStyle
    VisualElement.styleSheets
    VisualElement.tooltip
    Focusable.Blur()
    Focusable.focusable
    Focusable.tabIndex
    Focusable.delegatesFocus
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallbackOnce<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.RegisterCallbackOnce<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, CallbackOptions)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, CallbackOptions)
    CallbackEventHandler.UnregisterAllRemovableCallbacks()
    CallbackEventHandler.HasTrickleDownHandlers()
    CallbackEventHandler.HasBubbleUpHandlers()
    CallbackEventHandler.ExecuteDefaultActionAtTarget(EventBase)
    CallbackEventHandler.HandleEventBubbleUp(EventBase)
    CallbackEventHandler.HandleEventTrickleDown(EventBase)
    CallbackEventHandler.ExecuteDefaultAction(EventBase)
    CallbackEventHandler.NotifyPropertyChanged(in BindingId)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.AppUI.UI
    Assembly: Unity.AppUI.dll
    Syntax
    public class CurveEditor : VisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, INotifyValueChanged<AnimationCurve>, ICustomAnimationCurveFieldPicker
    Remarks

    The editor is the counterpart AnimationCurveField has been waiting for. It implements ICustomAnimationCurveFieldPicker, so assigning one to customPicker turns the field from a read-only curve thumbnail into an editable one — the same way ColorField and ColorPicker pair up.

    The curve and the grid are stroked with Painter2D, exactly as AnimationCurveField strokes its thumbnail, so no shader and no render texture are involved. Keys and tangent handles are real elements rather than painted marks, which is what lets them be hit-tested and styled from USS.

    The plotted range is taken from the curve on load: time spans the curve's own first and last key, and value spans [0, 1] widened to fit the curve — the same rule AnimationCurveField uses, so the thumbnail and the editor frame a curve identically. Editing clamps into that range rather than growing it, so the graph never moves under the pointer mid-drag.

    Interaction

    • Click a key to select it, drag to move it. The first and last key keep their time and move only in value, because they anchor the plotted range.
    • Drag a tangent handle to author the slope. Hold Alt to break the handle so the two sides move independently.
    • Double-click the graph to add a key there.
    • Delete or Backspace removes the selected key, never the last one. F flattens it.

    Two deliberate divergences from the registry. Tangent modes are chosen from a dropdown in the toolbar rather than from a right-click context menu, because UI Toolkit has no equivalent of the registry's absolutely positioned menu div and a dropdown is the package's own idiom for a mode list. And selection is single-key: there is no marquee box-select, so no group move, group delete or group flatten.

    Example

    var field = new AnimationCurveField { customPicker = new CurveEditor() };
    field.RegisterValueChangedCallback(evt => Debug.Log(evt.newValue));

    Constructors

    CurveEditor()

    Default constructor. Starts on the Ease In-Out preset.

    Declaration
    public CurveEditor()

    Fields

    graphUssClassName

    The graph styling class.

    Declaration
    public const string graphUssClassName = "appui-curveeditor__graph"
    Field Value
    Type Description
    string

    handleRadius

    How far from its key a tangent handle sits, in pixels. Fixed rather than proportional so the handle stays grabbable whatever the graph's aspect ratio.

    Declaration
    public const float handleRadius = 32
    Field Value
    Type Description
    float

    handleUssClassName

    The tangent handle styling class.

    Declaration
    public const string handleUssClassName = "appui-curveeditor__handle"
    Field Value
    Type Description
    string

    keyUssClassName

    The keyframe marker styling class.

    Declaration
    public const string keyUssClassName = "appui-curveeditor__key"
    Field Value
    Type Description
    string

    presetGlyphUssClassName

    The preset glyph styling class.

    Declaration
    public const string presetGlyphUssClassName = "appui-curveeditor__preset-glyph"
    Field Value
    Type Description
    string

    presetUssClassName

    The preset button styling class.

    Declaration
    public const string presetUssClassName = "appui-curveeditor__preset"
    Field Value
    Type Description
    string

    presetsUssClassName

    The presets row styling class.

    Declaration
    public const string presetsUssClassName = "appui-curveeditor__presets"
    Field Value
    Type Description
    string

    selectedKeyUssClassName

    The selected keyframe marker styling class.

    Declaration
    public const string selectedKeyUssClassName = "appui-curveeditor__key--selected"
    Field Value
    Type Description
    string

    tangentDropdownUssClassName

    The tangent mode dropdown styling class.

    Declaration
    public const string tangentDropdownUssClassName = "appui-curveeditor__tangent-dropdown"
    Field Value
    Type Description
    string

    toolbarUssClassName

    The toolbar styling class.

    Declaration
    public const string toolbarUssClassName = "appui-curveeditor__toolbar"
    Field Value
    Type Description
    string

    ussClassName

    The CurveEditor main styling class.

    Declaration
    public const string ussClassName = "appui-curveeditor"
    Field Value
    Type Description
    string

    Properties

    contentContainer

    Logical container where child elements are added. If a child is added to this element, the child is added to this element's content container instead.

    Declaration
    public override VisualElement contentContainer { get; }
    Property Value
    Type Description
    VisualElement
    Overrides
    VisualElement.contentContainer

    graphElement

    The element the curve, the grid and the tangent arms are stroked into. Key markers and tangent handles are its children.

    Declaration
    public VisualElement graphElement { get; }
    Property Value
    Type Description
    VisualElement

    inTangentHandle

    The incoming tangent handle of the selected key. Hidden when nothing is selected.

    Declaration
    public VisualElement inTangentHandle { get; }
    Property Value
    Type Description
    VisualElement

    keyMarkers

    The key markers, in time order.

    Declaration
    public IReadOnlyList<VisualElement> keyMarkers { get; }
    Property Value
    Type Description
    IReadOnlyList<VisualElement>

    outTangentHandle

    The outgoing tangent handle of the selected key. Hidden when nothing is selected.

    Declaration
    public VisualElement outTangentHandle { get; }
    Property Value
    Type Description
    VisualElement

    plotRect

    The area of graphElement the curve is plotted into, in graph-local pixels.

    Declaration
    public Rect plotRect { get; }
    Property Value
    Type Description
    Rect

    presets

    The available starting shapes.

    Declaration
    public static IReadOnlyList<CurveEditor.CurvePreset> presets { get; }
    Property Value
    Type Description
    IReadOnlyList<CurveEditor.CurvePreset>

    presetsElement

    The presets row.

    Declaration
    public VisualElement presetsElement { get; }
    Property Value
    Type Description
    VisualElement

    selectedKeyIndex

    The index of the selected key, or -1 when nothing is selected.

    Declaration
    public int selectedKeyIndex { get; }
    Property Value
    Type Description
    int

    tangentElement

    The tangent mode dropdown.

    Declaration
    public Dropdown tangentElement { get; }
    Property Value
    Type Description
    Dropdown

    value

    The curve being edited.

    Declaration
    [CreateProperty]
    public AnimationCurve value { get; set; }
    Property Value
    Type Description
    AnimationCurve
    Remarks

    The getter builds a fresh AnimationCurve on every read, so a consumer holding an earlier value never sees it mutate underneath them.

    Methods

    AddKey(float, float)

    Adds a key and selects it.

    Declaration
    public bool AddKey(float time, float value)
    Parameters
    Type Name Description
    float time

    Time of the new key, clamped to the plotted time range.

    float value

    Value of the new key, clamped to the plotted value range.

    Returns
    Type Description
    bool

    False when a key already sits at that time.

    ApplyPreset(int)

    Replaces the curve with a preset.

    Declaration
    public void ApplyPreset(int index)
    Parameters
    Type Name Description
    int index

    Index into presets.

    Dismiss()

    Closes the popover this editor was opened in, if any.

    Declaration
    public void Dismiss()

    DomainToPlot(float, float)

    Maps a point in curve space onto graphElement's local pixels.

    Declaration
    public Vector2 DomainToPlot(float time, float value)
    Parameters
    Type Name Description
    float time

    A time in the plotted range.

    float value

    A value in the plotted range.

    Returns
    Type Description
    Vector2

    The pixel position, with y growing downward.

    GetTangentMode(int)

    Returns the tangent mode of a key.

    Declaration
    public TangentMode GetTangentMode(int index)
    Parameters
    Type Name Description
    int index

    Index of the key.

    Returns
    Type Description
    TangentMode

    The key's mode, or Free for an out-of-range index.

    MoveSelectedKey(float, float)

    Moves the selected key.

    Declaration
    public void MoveSelectedKey(float time, float value)
    Parameters
    Type Name Description
    float time

    Target time. Clamped between the neighbouring keys; ignored for the first and last key, which anchor the plotted time range.

    float value

    Target value, clamped to the plotted value range.

    PlotToDomain(Vector2)

    Maps a point in graphElement's local pixels back into curve space.

    Declaration
    public Vector2 PlotToDomain(Vector2 local)
    Parameters
    Type Name Description
    Vector2 local

    A pixel position, with y growing downward.

    Returns
    Type Description
    Vector2

    The time in x and the value in y, both unclamped.

    RemoveSelectedKey()

    Removes the selected key.

    Declaration
    public bool RemoveSelectedKey()
    Returns
    Type Description
    bool

    False when nothing is selected, or when it is the only key left.

    SelectKey(int)

    Selects a key.

    Declaration
    public void SelectKey(int index)
    Parameters
    Type Name Description
    int index

    Index of the key. Out-of-range clears the selection.

    SetTangent(int, TangentSide, float)

    Authors one tangent by hand.

    Declaration
    public void SetTangent(int index, CurveEditor.TangentSide side, float slope)
    Parameters
    Type Name Description
    int index

    Index of the key.

    CurveEditor.TangentSide side

    Which tangent to set.

    float slope

    The slope, in value units per time unit.

    Remarks

    On a Broken key only the named side moves. On any other mode the key becomes Free and both sides take the slope, which keeps the curve smooth through the key.

    SetTangentMode(int, TangentMode)

    Sets the tangent mode of a key and re-derives its tangents.

    Declaration
    public void SetTangentMode(int index, TangentMode mode)
    Parameters
    Type Name Description
    int index

    Index of the key.

    TangentMode mode

    The mode to apply.

    SetValueWithoutNotify(AnimationCurve)

    Sets the curve without sending a change event.

    Declaration
    public void SetValueWithoutNotify(AnimationCurve newValue)
    Parameters
    Type Name Description
    AnimationCurve newValue

    The curve to edit. Null resets to the default.

    Remarks

    Incoming keys land in Free so their authored tangents are preserved exactly. Defaulting them to a solved mode would silently re-derive — and therefore change — a curve the caller only asked to display.

    Show(AnimationCurveField, Action<AnimationCurve>, AnimationCurve)

    Opens the editor in a Popover anchored to the field, as ColorField does with ColorPicker.

    Declaration
    public void Show(AnimationCurveField owner, Action<AnimationCurve> onValueChanging, AnimationCurve initialValue)
    Parameters
    Type Name Description
    AnimationCurveField owner

    The field that requested the editor.

    Action<AnimationCurve> onValueChanging

    Invoked as the user edits.

    AnimationCurve initialValue

    The curve assigned when the editor opened.

    Implements

    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    INotifyValueChanged<T>
    ICustomAnimationCurveFieldPicker

    Extension Methods

    VisualElementExtensions.FindNavController(VisualElement)
    RegisterUpdateCallbackExtensions.RegisterUpdateCallback(VisualElement, EventCallback<UpdateEvent>)
    RegisterUpdateCallbackExtensions.UnregisterUpdateCallback(VisualElement, EventCallback<UpdateEvent>)
    VisualElementExtensions.EnableDynamicTransform(VisualElement, bool)
    VisualElementExtensions.EnablePicking(VisualElement, bool)
    VisualElementExtensions.GetChildren<T>(VisualElement, bool)
    VisualElementExtensions.GetContextProvider<T>(VisualElement)
    VisualElementExtensions.GetContextProvider<T>(VisualElement, string)
    VisualElementExtensions.GetContext<T>(VisualElement)
    VisualElementExtensions.GetContext<T>(VisualElement, string)
    VisualElementExtensions.GetExclusiveRootElement(VisualElement)
    VisualElementExtensions.GetLastAncestorOfType<T>(VisualElement)
    VisualElementExtensions.GetPreferredTooltipPlacement(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement, string)
    VisualElementExtensions.GetTooltipContent(VisualElement)
    VisualElementExtensions.GetTooltipTemplate(VisualElement)
    VisualElementExtensions.HasAncestorOfType<T>(VisualElement, bool)
    VisualElementExtensions.HasAncestorsOfType<T>(VisualElement)
    VisualElementExtensions.IsContextProvider<T>(VisualElement)
    VisualElementExtensions.IsContextProvider<T>(VisualElement, string)
    VisualElementExtensions.IsInvisible(VisualElement)
    VisualElementExtensions.IsOnScreen(VisualElement)
    VisualElementExtensions.ProvideContext<T>(VisualElement, string, T)
    VisualElementExtensions.ProvideContext<T>(VisualElement, T)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, string, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.SetPreferredTooltipPlacement(VisualElement, OptionalEnum<PopoverPlacement>)
    VisualElementExtensions.SetTooltipContent(VisualElement, VisualElementExtensions.TooltipContentCallback)
    VisualElementExtensions.SetTooltipTemplate(VisualElement, VisualElement)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, string, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)