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
- Type: Class
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
- Inherits from: Attribute
[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
Constructor | Description |
|---|---|
| RegisterCallbackAttribute(System.Type,UnityEngine.UIElements.CallbackOptions) | Initializes a new instance of the RegisterCallbackAttribute class. |
Properties
Property | Description |
|---|---|
| callbackOptions | Options that control how the callback is registered, such as CallbackOptions.TrickleDown. |
| eventType | The type of event to handle, for example |