Class UxmlFactory<TCreatedType, TTraits>
Generic base class for UXML factories, which instantiate a VisualElement using the data read from a UXML file.
Namespace: UnityEngine.UIElements
Syntax
public class UxmlFactory<TCreatedType, TTraits> : object, IUxmlFactory where TCreatedType : VisualElement, new()
where TTraits : UxmlTraits, new()
Type Parameters
Name | Description |
---|---|
TCreatedType | |
TTraits |
Remarks
/T0/ The type of the element that will be instantiated. It must derive from VisualElement.
/T1/ The traits of the element that will be instantiated. It must derive from UxmlTraits.
Constructors
UxmlFactory()
Declaration
protected UxmlFactory()
Properties
canHaveAnyAttribute
Returns UxmlTraitscanHaveAnyAttribute (where UxmlTraits is the argument for T1
).
Declaration
public bool canHaveAnyAttribute { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
substituteForTypeName
Returns an empty string if T0
is not VisualElement; otherwise, returns "VisualElement".
Declaration
public virtual string substituteForTypeName { get; }
Property Value
Type | Description |
---|---|
String |
Implements
substituteForTypeNamespace
Returns the namespace for substituteForTypeName.
Declaration
public virtual string substituteForTypeNamespace { get; }
Property Value
Type | Description |
---|---|
String |
Implements
substituteForTypeQualifiedName
Returns the fully qualified name for substituteForTypeName.
Declaration
public virtual string substituteForTypeQualifiedName { get; }
Property Value
Type | Description |
---|---|
String |
Implements
uxmlAttributesDescription
Returns an empty enumerable.
Declaration
public virtual IEnumerable<UxmlAttributeDescription> uxmlAttributesDescription { get; }
Property Value
Type | Description |
---|---|
IEnumerable<UxmlAttributeDescription> |
Implements
uxmlChildElementsDescription
Returns an empty enumerable.
Declaration
public virtual IEnumerable<UxmlChildElementDescription> uxmlChildElementsDescription { get; }
Property Value
Type | Description |
---|---|
IEnumerable<UxmlChildElementDescription> |
Implements
uxmlName
Returns the type name of T0
.
Declaration
public virtual string uxmlName { get; }
Property Value
Type | Description |
---|---|
String |
Implements
uxmlNamespace
Returns the namespace name of T0
.
Declaration
public virtual string uxmlNamespace { get; }
Property Value
Type | Description |
---|---|
String |
Implements
uxmlQualifiedName
Returns the typefully qualified name of T0
.
Declaration
public virtual string uxmlQualifiedName { get; }
Property Value
Type | Description |
---|---|
String |
Implements
Methods
AcceptsAttributeBag(IUxmlAttributes, CreationContext)
Returns true.
Declaration
public virtual bool AcceptsAttributeBag(IUxmlAttributes bag, CreationContext cc)
Parameters
Type | Name | Description |
---|---|---|
IUxmlAttributes | bag | The attribute bag. |
CreationContext | cc |
Returns
Type | Description |
---|---|
Boolean | Always true. |
Implements
Remarks
By default, accepts any attribute bags. Override this function if you want to make specific checks on the attribute bag.
Create(IUxmlAttributes, CreationContext)
Instantiate an object of type T0
and initialize it by calling T1
UxmlTraits
Declaration
public virtual 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 element. |