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

UxmlAttributeField Constructor

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 UxmlAttributeField();

Description

Creates an unbound field. Set UxmlAttributeField.bindingPath to bind it to a serialized property.

The field starts unbound. Set UxmlAttributeField.bindingPath to bind it, or use UxmlAttributeField.UxmlAttributeField to bind it when you create it.

The following example creates an unbound field and sets <see cref="Unity.UIToolkit.Editor.UxmlAttributeField._bindingPath" /> to bind it.

var field = new UxmlAttributeField();
field.bindingPath = "text";
container.Add(field);

Declaration

public UxmlAttributeField(SerializedProperty property);

Parameters

Parameter Description
property The property to display and edit. Pass null to create an unbound field.

Description

Creates a field bound to the given serialized property.

When property is null, the field starts unbound. Set UxmlAttributeField.bindingPath after you create it, or use the parameterless constructor.

The following example creates a field bound to a property from <c>FindPropertyRelative</c>.

var textProperty = property.FindPropertyRelative("text");
if (textProperty != null)
{
    var field = new UxmlAttributeField(textProperty);
    field.label = "Text Content";
    container.Add(field);
}