Documentation

Unity Engine

Download Unity

Unity Engine

RegisterCallbackAttribute

Declares a static method of a component struct as an event handler for the element the component is attached to.
Read time 4 minutesLast updated 10 hours ago

Definition

[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]public class RegisterCallbackAttribute : Attribute

Remarks

Apply this attribute to a static method of a struct that has the VisualElementComponentAttribute. When the component is added to an element, the method is registered as a callback for RegisterCallbackAttribute.eventType on that element; when the component is removed, the callback is unregistered.
Apply the attribute several times to handle several event types with the same method. Unity's source generator validates the method signature and generates the registration code.
The
ref T self
parameter is valid only until the element's components change. For the rules that apply to it, refer to VisualElementComponentAttribute.

Constructors

Properties

Property

Description

callbackOptionsOptions that control how the callback is registered, such as CallbackOptions.TrickleDown.
eventTypeThe type of event to handle, for example
typeof(PointerDownEvent)
.

Inheritance

Inherited Members