docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class OptionalPropertyDrawer<T, TU>

    Draws the Inspector GUI for an optional property

    Inheritance
    object
    GUIDrawer
    PropertyDrawer
    OptionalPropertyDrawer<T, TU>
    OptionalColorDrawer
    OptionalRectDrawer
    OptionalScaleDrawer
    OptionalStringDrawer
    OptionalThemeDrawer
    OptionalValuePropertyDrawer<T, TU>
    Inherited Members
    PropertyDrawer.OnGUI(Rect, SerializedProperty, GUIContent)
    PropertyDrawer.GetPropertyHeight(SerializedProperty, GUIContent)
    PropertyDrawer.CanCacheInspectorGUI(SerializedProperty)
    PropertyDrawer.attribute
    PropertyDrawer.fieldInfo
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.AppUI.Editor
    Assembly: Unity.AppUI.Editor.dll
    Syntax
    public class OptionalPropertyDrawer<T, TU> : PropertyDrawer where TU : BindableElement, INotifyValueChanged<T>, new()
    Type Parameters
    Name Description
    T

    The type of the optional property

    TU

    The type of the field used to edit the value of the optional property

    Fields

    m_HasValue

    Whether the optional property has a value

    Declaration
    protected SerializedProperty m_HasValue
    Field Value
    Type Description
    SerializedProperty

    m_HasValueField

    The toggle component used to edit the hasValue property

    Declaration
    protected Toggle m_HasValueField
    Field Value
    Type Description
    Toggle

    m_Value

    The value of the optional property

    Declaration
    protected SerializedProperty m_Value
    Field Value
    Type Description
    SerializedProperty

    m_ValueField

    The field component used to edit the value property

    Declaration
    protected TU m_ValueField
    Field Value
    Type Description
    TU

    Methods

    CreatePropertyGUI(SerializedProperty)

    Creates custom GUI with UI Toolkit for the property.

    Declaration
    public override VisualElement CreatePropertyGUI(SerializedProperty property)
    Parameters
    Type Name Description
    SerializedProperty property

    The SerializedProperty to make the custom GUI for.

    Returns
    Type Description
    VisualElement

    The element containing the custom GUI.

    Overrides
    PropertyDrawer.CreatePropertyGUI(SerializedProperty)

    SetValue(T)

    Sets the value of the property in the serialized object

    Declaration
    protected virtual void SetValue(T newValue)
    Parameters
    Type Name Description
    T newValue

    The new value of the property

    In This Article
    Back to top
    Copyright © 2025 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)