Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

UxmlSerializedDataPropertyDrawer

class in Unity.UIToolkit.Editor

/

Inherits from:PropertyDrawer

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

A base property drawer for UXML serialized data that renders attribute fields in the Inspector.

Derive from UxmlSerializedDataPropertyDrawer and apply CustomPropertyDrawer for a UxmlSerializedData type to customize how its attributes appear in the authoring Inspector. The base class generates a field for each visible attribute. Override UxmlSerializedDataPropertyDrawer.CreateChildPropertiesGUI to control which attributes appear and in what order, and UxmlSerializedDataPropertyDrawer.CreateChildPropertyGUI to control how each one is drawn.

Additional resources: UxmlAttributeField, UxmlAttributeFieldDecorator

The following example defines a minimal drawer that uses the default field generation.

// Inherit from UxmlSerializedDataPropertyDrawer and apply it to a UxmlSerializedData class.
// The [CustomPropertyDrawer] attribute associates this drawer with ColorfulButton.UxmlSerializedData.
[CustomPropertyDrawer(typeof(ColorfulButton.UxmlSerializedData))]
public class ColorfulButtonDrawer : UxmlSerializedDataPropertyDrawer
{
    // The base class generates property fields for all [UxmlAttribute] properties automatically.
    // Override CreateChildPropertiesGUI or CreateChildPropertyGUI to customize the layout.
}

Public Methods

Method Description
CreatePropertyGUI Creates the root element for the property GUI. This method is sealed.

Protected Methods

Method Description
CreateChildPropertiesExcluding Creates a field for each visible attribute of the UXML serialized data, excluding the specified attributes.
CreateChildPropertiesGUI Creates a field for each visible attribute of the UXML serialized data.
CreateChildPropertiesIncluding Creates a field only for the specified attributes of the UXML serialized data.
CreateChildPropertyGUI Creates the GUI for a single attribute of the UXML serialized data.

Inherited Members

Properties

PropertyDescription
attributeThe PropertyAttribute for the property. Not applicable for custom class drawers. (Read Only)
fieldInfoThe reflection FieldInfo for the member this property represents. (Read Only)
preferredLabelThe label for this property. (Read Only)

Public Methods

MethodDescription
GetPropertyHeightOverride this method to specify how tall the GUI for this field is in pixels.
OnGUIOverride this method to make your own IMGUI based GUI for the property.