# RegisterEventHandler

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

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.MPE](/engine/6000.5/script-reference/unityeditor/mpe.md)
* **Assembly:** UnityEditor.CoreModule

## RegisterEventHandler(string, Action\<string, Object\[]>)

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](/engine/6000.5/script-reference/unityeditor/mpe/eventservice/emit.md) or [EventService.Request](/engine/6000.5/script-reference/unityeditor/mpe/eventservice/request.md).

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

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The event type name.**** (\[Action\<string, Object\[]>]\(https\://learn.microsoft.com/dotnet/api/system.action)): The handler.

### Returns

| Type                                                           | Description                                                      |
| -------------------------------------------------------------- | ---------------------------------------------------------------- |
| [Action](https://learn.microsoft.com/dotnet/api/system.action) | An action that, when invoked, unregisters the handler (see Off). |

## RegisterEventHandler(string, Func\<string, Object\[], Object>)

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](/engine/6000.5/script-reference/unityeditor/mpe/eventservice/emit.md) or [EventService.Request](/engine/6000.5/script-reference/unityeditor/mpe/eventservice/request.md).

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

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The event type name.**** (\[Func\<string, Object\[], Object>]\(https\://learn.microsoft.com/dotnet/api/system.func-1)): The handler.

### Returns

| Type                                                           | Description                                                      |
| -------------------------------------------------------------- | ---------------------------------------------------------------- |
| [Action](https://learn.microsoft.com/dotnet/api/system.action) | An action that, when invoked, unregisters the handler (see Off). |
