UxmlSerializedDataPropertyDrawer
A base property drawer for UXML serialized data that renders attribute fields in the Inspector.
Read time 1 minuteLast updated 8 days ago
Definition
- Type: Class
- Namespace: Unity.UIToolkit.Editor
- Assembly: UnityEditor
- Inherits from: PropertyDrawer
[CustomPropertyDrawer(typeof(UxmlSerializedData), true)]public class UxmlSerializedDataPropertyDrawer : PropertyDrawer
Remarks
Derive from UxmlSerializedDataPropertyDrawer and apply CustomPropertyDrawer for a 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.
UxmlSerializedDataAdditional Resources: UxmlAttributeField, UxmlAttributeFieldDecorator
The following example defines a minimal drawer that uses the default field generation.
Examples
// 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.}
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. |
| CreatePropertyGUI | Creates the root element for the property GUI. This method is sealed. |