IVisualElementComponent
The interface for all UI Toolkit component structs.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Interface
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
public interface IVisualElementComponent
Remarks
You don't implement this interface yourself: when you declare a with the VisualElementComponentAttribute, Unity's source generator adds the interface to the generated part of the struct. The interface is an implementation detail of that generator: its members are not a stable API, and Unity can add, change, or remove them in any version. The component methods on VisualElement, such as VisualElement.AddComponent, accept any struct that has it. The hooks are emitted by the source generator, never written by hand. They let / (un)register a component's handlers and validate its owner constraint through a constrained generic call, resolved by the compiler, so there is no reflection and no boxing of the component struct. A component that declares no callbacks (or no owner constraint) gets empty generated bodies. The storage hot path () never calls these, so it is unaffected.
partial structAddComponentRemoveComponent[RegisterCallback][RequiresElementOfType]GetComponent