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

UxmlSerializedDataPropertyDrawer.CreatePropertyGUI

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

Declaration

public VisualElement CreatePropertyGUI(SerializedProperty property);

Parameters

Parameter Description
property The property that represents the UxmlSerializedData instance.

Returns

VisualElement The root element for the Inspector.

Description

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


Declaration

protected void CreatePropertyGUI(VisualElement container, SerializedProperty property);

Parameters

Parameter Description
container The parent element to add the content to.
property The serialized property that represents the UXML serialized data instance.

Description

Creates the property GUI for a UXML serialized data instance.

The default implementation wraps the child properties in a Foldout with the property display name as its label. Override this method to use a flat layout or a different container.

The following example replaces the default foldout with a flat layout.

// Override CreatePropertyGUI to replace the default Foldout with a flat layout.
[CustomPropertyDrawer(typeof(FlatButton.UxmlSerializedData))]
public class FlatButtonDrawer : UxmlSerializedDataPropertyDrawer
{
    protected override void CreatePropertyGUI(VisualElement container, SerializedProperty property)
    {
        VisualElement group = new VisualElement();
        container.Add(group);
        if (property.managedReferenceValue != null)
            CreateChildPropertiesGUI(group, property);
    }
}