Class UxmlTraits
Describes a VisualElement derived class for the parsing of UXML files and the generation of UXML schema definition.
Namespace: UnityEngine.UIElements
Syntax
public abstract class UxmlTraits : object
Remarks
UxmlTraits describes the UXML attributes and children elements of a class deriving from VisualElement. It is used by
Constructors
UxmlTraits()
Declaration
protected UxmlTraits()
Properties
canHaveAnyAttribute
Must return true if the UXML element attributes are not restricted to the values enumerated by uxmlAttributesDescription.
Declaration
public bool canHaveAnyAttribute { get; protected set; }
Property Value
Type | Description |
---|---|
Boolean |
uxmlAttributesDescription
Describes the UXML attributes expected by the element. The attributes enumerated here will appear in the UXML schema.
Declaration
public virtual IEnumerable<UxmlAttributeDescription> uxmlAttributesDescription { get; }
Property Value
Type | Description |
---|---|
IEnumerable<UxmlAttributeDescription> |
uxmlChildElementsDescription
Describes the types of element that can appear as children of this element in a UXML file.
Declaration
public virtual IEnumerable<UxmlChildElementDescription> uxmlChildElementsDescription { get; }
Property Value
Type | Description |
---|---|
IEnumerable<UxmlChildElementDescription> |
Methods
Init(VisualElement, IUxmlAttributes, CreationContext)
Initialize a VisualElement instance with values from the UXML element attributes.
Declaration
public virtual void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
Parameters
Type | Name | Description |
---|---|---|
VisualElement | ve | The VisualElement to initialize. |
IUxmlAttributes | bag | A bag of name-value pairs, one for each attribute of the UXML element. |
CreationContext | cc | When the element is created as part of a template instance inserted in another document, this contains information about the insertion point. |
Remarks
Override this function in your traits class to initialize your C# object with values read from the UXML document.