The name of the component(script) that contains target callback, such as the name 'MainMenu' of the script in the example
Custom Event Data
Event handler, such as the callback function name 'onClick' in the example
The node that contains target component
Trigger the target callback with given arguments
The arguments for invoking the callback
Dispatching component events.
The event list to be emitted
The callback arguments
Generated using TypeDoc
The EventHandler class sets the event callback in the scene. This class allows the user to set the callback target node, target component name, component method name, and call the target method through the
emit
method.// Let's say we have a MainMenu component on newTarget // file: MainMenu.ts @ccclass('MainMenu') export class MainMenu extends Component { // sender: the node MainMenu.ts belongs to // eventType: CustomEventData onClick (sender, eventType) { cc.log('click'); } } import { Component } from 'cc'; const eventHandler = new Component.EventHandler(); eventHandler.target = newTarget; eventHandler.component = "MainMenu"; eventHandler.handler = "OnClick"; eventHandler.customEventData = "my data";