Skip to content

Signal and Signal Receiver

A signal lets a scheme change your scene without code. Three things carry it: a Signal asset, a Send Signal node, and a Signal Receiver on a scene object. This page covers the two Inspectors and the Studio field. For the idea behind it, see Signals. For the node, see Send Signal.

Create one with Create > MrW > Intrigues > Signal. The file starts as New Signal. It holds one field.

Field What it does
Description A note for your team: when is this signal sent, and what should react to it? A text area. It has no effect on the game.

Under it, the Inspector reads your project and shows:

Part What it shows
SENT BY The Send Signal nodes that send this signal, each with an Open button that shows the node in the Studio. With none: “No Send Signal node sends this signal. Code can still send it with IM.Signal.”
LISTENERS IN OPEN SCENES The Signal Receivers in the open scenes that react to it, each a button that selects the object. With none: “No Signal Receiver in the open scenes reacts to this signal.”
Send Now Sends the signal as a scheme would. It works in Play mode only; before that the hint says so.

With several signals selected, it says to select one to see who sends it and who listens.

Add it from Add Component > Intrigues > Signal Receiver. One per object. Its header line reads “Runs actions in this scene when a scheme sends a signal.” The status says Listening for signals, or Not listening (switched off) when the object or the component is off.

REACTIONS is a list of cards. Add Reaction adds one. With none, the Inspector says “No reactions yet”, explains that a reaction links one signal to what should happen in the scene, and adds “You can also drop Signal assets here.” A SETTINGS block lists any other fields a subclass of yours adds. In Play mode a note says that changes made here are lost when you stop.

A reaction is one signal plus one Unity event. Its fields:

Field What it does
Signal The signal this reaction runs for. Hover: “The reaction runs when a Send Signal node, or code, sends this signal.” A reaction with no signal never runs. New next to it creates a Signal asset and uses it; it does not work in Play mode.
Do This A Unity event: the actions to run. A reaction takes no arguments.

A card also has a one-line summary (the target and the action), Sent by: links to the sending nodes, Run Now (Play mode: runs the reaction as if its signal had been sent), Duplicate, move up and down, and remove. The same actions are in the card’s context menu. In Play mode a card says “not run yet”, or how often it ran and how long ago.

The card warns about these mistakes:

Message Meaning
Choose a signal. Without one this reaction never runs. No signal set.
The signal asset is missing. Choose another one or restore the asset. The asset was deleted.
An action has no object or no function chosen. A broken line in Do This.
No action in the inspector yet. Add one under Do This, or add a listener from code. Nothing to run.
This object is switched off, so the receiver does not hear signals. Put the Signal Receiver on an object that stays on; it can still switch this one on. The object or a parent is off.
This Signal Receiver is switched off (the checkbox above), so it does not hear signals. The component’s checkbox is off.
This reaction switches off the object the Signal Receiver is on. After that the receiver stops listening.

The receiver listens while its object is active and the component is enabled. It runs on the main thread. When a signal arrives, every reaction to it runs, top to bottom. An action that throws is logged; the later actions of that reaction are skipped, and the other reactions still run. Reactions are not saved with the game: for a lasting change, send the signal again from an On Game Loaded node.

The Send Signal node’s Signal field is an object field for Signal assets, with a New button that opens a save dialog (New Signal) and puts the new asset in the field. New is off in Play mode.

Members read from SignalReceiver.cs and IM.Signals.cs.

Signature What it does
SignalReceiver.AddReaction(Signal signal, UnityAction action = null) Adds a reaction at the end; returns it.
SignalReceiver.RemoveReactions(Signal signal) Removes every reaction to the signal; returns how many.
SignalReceiver.ReactsTo(Signal signal) True when at least one reaction runs for it.
IM.Signal(Signal signal) Sends a signal from code.
IM.CurrentSignal A SignalContext with the signal, conspirator, target and scheme, while one is handled.

Example, not compiled. It is built from the signatures above.

receiver.AddReaction(spursGiven, () => Debug.Log("Spurs given"));
IM.Signal(spursGiven);