Documentation

Unity Engine


User Manual

Script Reference

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 7 days 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 _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.

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