Interface IUxmlFactory
Interface for UXML factories. While it is not strictly required, concrete factories should derive from the generic class
Namespace: UnityEngine.UIElements
Syntax
public interface IUxmlFactory
Properties
canHaveAnyAttribute
Must return true if the UXML element attributes are not restricted to the values enumerated by uxmlAttributesDescription.
Declaration
bool canHaveAnyAttribute { get; }
Property Value
Type | Description |
---|---|
Boolean |
substituteForTypeName
The type of element for which this element type can substitute for.
Declaration
string substituteForTypeName { get; }
Property Value
Type | Description |
---|---|
String |
Remarks
Enables the element to appear anywhere the substituteForTypeName element can appear in a UXML document.
For example, if an element restricts its children to Button elements (using the uxmlChildElementsDescription property), elements that have Button
are accepted as children of that element.
The value of this property is used for the element's substitutionGroup attribute in UXML schema definition.
substituteForTypeNamespace
The UXML namespace for the type returned by substituteForTypeName.
Declaration
string substituteForTypeNamespace { get; }
Property Value
Type | Description |
---|---|
String |
substituteForTypeQualifiedName
The fully qualified XML name for the type returned by substituteForTypeName.
Declaration
string substituteForTypeQualifiedName { get; }
Property Value
Type | Description |
---|---|
String |
uxmlAttributesDescription
Describes the UXML attributes expected by the element. The attributes enumerated here will appear in the UXML schema.
Declaration
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
IEnumerable<UxmlChildElementDescription> uxmlChildElementsDescription { get; }
Property Value
Type | Description |
---|---|
IEnumerable<UxmlChildElementDescription> |
uxmlName
The name of the UXML element read by the factory.
Declaration
string uxmlName { get; }
Property Value
Type | Description |
---|---|
String |
uxmlNamespace
The namespace of the UXML element read by the factory.
Declaration
string uxmlNamespace { get; }
Property Value
Type | Description |
---|---|
String |
uxmlQualifiedName
The fully qualified name of the UXML element read by the factory.
Declaration
string uxmlQualifiedName { get; }
Property Value
Type | Description |
---|---|
String |
Methods
AcceptsAttributeBag(IUxmlAttributes, CreationContext)
Returns true if the factory accepts the content of the attribute bag.
Declaration
bool AcceptsAttributeBag(IUxmlAttributes bag, CreationContext cc)
Parameters
Type | Name | Description |
---|---|---|
IUxmlAttributes | bag | The attribute bag. |
CreationContext | cc |
Returns
Type | Description |
---|---|
Boolean | True if the factory accepts the content of the attribute bag. False otherwise. |
Remarks
Use this function to validate the content of the attribute bag against the requirements of your factory. If a required attribute is missing or if an attribute value is incorrect, return false. Otherwise, if the bag content is acceptable to your factory, return true.
Create(IUxmlAttributes, CreationContext)
Instantiate and initialize an object of type T0
.
Declaration
VisualElement Create(IUxmlAttributes bag, CreationContext cc)
Parameters
Type | Name | Description |
---|---|---|
IUxmlAttributes | bag | A bag of name-value pairs, one for each attribute of the UXML element. This can be used to initialize the properties of the created object. |
CreationContext | cc | When the element is created as part of a template instance inserted in another document, this contains information about the insertion point. |
Returns
Type | Description |
---|---|
VisualElement | The created object. |