For the complete documentation index, see llms.txt. This page is also available as Markdown.

📣MEvent Listener

Last updated AC v1.5.3

Overview

The MEvent Listener Component is a List of MEvents Assets.

It uses Unity Events to send the data received by each MEvent to all the components attached to a gameObject.

Is heavily based on the Talk about Scriptable Architecture by Ryan Ripple

Properties

When a MEvent is selected on the list it will show the Description of the MEvent on a Green Help Box. You will also gain access to the different type of Responses.

Owner Filter

The Owner Filter lets one listener ignore invocations that were raised by somebody else. It uses the event's Sender, so the object that raises the event must call SetSender() on the MEvent first.

The filter applies to every entry on the component. Entries can opt out one by one.

[Insert Image - Owner Filter fields on the MEvent Listener]

Filter Mode

How the Sender is checked against the Owner.

  • Ignore: no filtering. The listener responds to every invocation. This is the default.

  • MustMatch: the listener responds only when the Sender belongs to the Owner.

  • MustNotMatch: the listener responds only when the Sender does not belong to the Owner.

When the Filter Mode is Ignore the Owner and Match Hierarchy fields are hidden.

Owner

The owner this listener belongs to. It is a Transform Reference, so it accepts a scene Transform or a TransformVar asset.

If the Owner is empty, or the event has no Sender, the check never matches. With MustMatch the listener stays silent, with MustNotMatch it always responds.

You can also set the Owner from code with SetOwner(Transform). That runtime override wins over the Owner field, which is useful when a spawner creates the listener and binds it to a player.

Match Hierarchy

On: the Sender matches when it shares the same hierarchy as the Owner, so any child bone or weapon of the owner counts as the owner. Off: the Sender must be the exact same Transform.

Use case: per-player UI in local multiplayer.

One MEvent asset can drive the UI of every player. Whoever raises the event calls SetSender() on it first, passing itself. Each player's UI listener sets its Filter Mode to MustMatch and its Owner to that player.

When Player 1 raises the event, only Player 1's UI responds. Player 2's listener skips it. You do not need one MEvent asset per player.

Void Response

Receive an void value from the event.

Bool Response

Receive an bool value from the event.

Float Response

Receive an float value from the event.

Int Response

Receive an integer value from the event.

Use Advanced Integer

By enabling this option the Int Comparer list will be showed. That way you can response to an specific value of the Integer value sent by the event.

String Response

Receive an string value from the event.

GameObject(GO) Response

Receive an gameObject value from the event.

Transform (T) Response

Receive an Transform value from the event.

Vector3 (V3) Response

Receive an Vector3 value from the event.

Vector2 (V2) Response

Receive an Vector2 value from the event.

Sender Response

Fires the object that raised the event, resolved to a Transform, when this entry responds.

It requires the raiser to have called SetSender() on the MEvent. Otherwise it fires null.

The Sender Response fires before the other responses of the entry, and it fires even when the entry's own response type is disabled.

Ignore Owner Filter

This entry always responds, bypassing the component's Owner Filter. The toggle only shows when the Filter Mode is not Ignore.

Debug

Logs on the Console when the entry starts and stops listening, when it responds, and why it was skipped: the Owner Filter, a disabled entry, or a disabled response type. The log also prints the Sender name.

Last updated