UxmlTypeReferenceAttribute

class in UnityEngine.UIElements

/

Inherits from:PropertyAttribute

/

Implemented in:UnityEngine.UIElementsModule

Description

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; } }

Properties

baseType The base type that the value inherits from.

Constructors

UxmlTypeReferenceAttribute Provides information about the expected type when applied to a Type field or property that has the UxmlAttributeAttribute attribute.

Inherited Members

Properties

applyToCollectionMakes attribute affect collections instead of their items.
orderOptional field to specify the order that multiple DecorationDrawers should be drawn in.

Did you find this page useful? Please give it a rating: