Version: 2021.3
LanguageEnglish
  • C#

EventService.RegisterEventHandler

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static Action RegisterEventHandler(string eventType, Action<string,object[]> handler);

Declaration

public static Action RegisterEventHandler(string eventType, Func<string,object[],object> handler);

Parameters

eventType The event type name.
handler The handler.

Returns

Action An action that, when invoked, unregisters the handler (see EventService.Off).

Description

Registers a handler for a specific event type. The handler is called whenever a message of the specified type is sent. Messages are sent using EventService.Emit or EventService.Request.