Class SignalEmitterComponent
Gameplay MonoBehaviour that dispatches Inspector-authored
UnityEventDispatcherSignalDefinition assets through the
IEventDispatcherService.
Holds a list of signal definitions and exposes Dispatch(string), which builds and
dispatches the definition whose Id matches the
supplied id. Wire Dispatch(string) (or DispatchFirst()) to a collision,
input callback, animation event or UnityEvent to emit a signal from a gameplay object.
Namespace: Serenity.EventDispatcher.Infrastructure.Components
Assembly: Serenity.UnityGlobal.Infrastructure.dll
Syntax
public class SignalEmitterComponent : MonoBehaviour
Constructors
SignalEmitterComponent()
Declaration
public SignalEmitterComponent()
Properties
SignalDefinitions
Gets the signal definitions this emitter can dispatch.
Declaration
public IReadOnlyList<UnityEventDispatcherSignalDefinition> SignalDefinitions { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<UnityEventDispatcherSignalDefinition> |
Methods
Dispatch(string)
Builds and dispatches the signal whose definition Id
matches id.
No-ops (with a warning) when no definition matches the id, when the matched definition is null,
or when the IEventDispatcherService is unavailable. Build/dispatch failures are
logged and swallowed so a misconfigured asset cannot break the calling gameplay flow.
Declaration
public bool Dispatch(string id)
Parameters
| Type | Name | Description |
|---|---|---|
| string | id | The Id of the signal to dispatch. |
Returns
| Type | Description |
|---|---|
| bool |
|
DispatchFirst()
Builds and dispatches the first configured signal definition.
Convenience for emitters that only carry a single signal, so the id does not have to be repeated.
Declaration
public bool DispatchFirst()
Returns
| Type | Description |
|---|---|
| bool |
|
DispatchFirstSignal()
Dispatches the first configured signal definition, for wiring into a UnityEngine.Events.UnityEvent such as a Button's On Click.
Declaration
public void DispatchFirstSignal()
Remarks
The void counterpart of DispatchFirst(); see DispatchSignal(string) for why a
bool-returning method cannot be bound to a UnityEvent.
DispatchSignal(string)
Dispatches the signal definition with id, for wiring into a
UnityEngine.Events.UnityEvent such as a Button's On Click.
Declaration
public void DispatchSignal(string id)
Parameters
| Type | Name | Description |
|---|---|---|
| string | id | Id of the signal definition to dispatch. |
Remarks
A UnityEvent binds a UnityAction, which must return void, so the inspector cannot
invoke Dispatch(string) even though it appears in the method dropdown — the binding
throws at runtime. This void form is the one to pick for no-code wiring; use
Dispatch(string) from C# when the result matters.