class in UnityEngine.UIElements
/
Inherits from:PropertyAttribute
/
Implemented in:UnityEngine.UIElementsModule
Provides information about the expected type when applied to a Type field or property that has the UxmlAttributeAttribute attribute.
When defining a Type field or property with the UxmlAttributeAttribute in Unity, you can use the UxmlTypeReference
attribute to specify the base type that the value should inherit from.
This allows you to provide additional information about the expected type of the value and helps Unity ensure that the
correct type is assigned to the attribute.
The following example creates a custom control and restricts the attribute type to only accept values that are derived from VisualElement:
using System; using UnityEngine.UIElements;
[UxmlElement] public partial class TypeRestrictionExample : VisualElement { [UxmlAttribute, UxmlTypeReference(typeof(VisualElement))] public Type elementType { get; set; } }
baseType | The base type that the value inherits from. |
UxmlTypeReferenceAttribute | Provides information about the expected type when applied to a Type field or property that has the UxmlAttributeAttribute attribute. |
order | Optional field to specify the order that multiple DecorationDrawers should be drawn in. |