Change the scene without code
The goal
Section titled “The goal”When something happens in a scheme, an object in your scene reacts: a door opens, a banner appears, a light goes out.
Do it, step by step
Section titled “Do it, step by step”- Create a signal with Create > MrW > Intrigues > Signal. In Description, write when it is sent and what should react.
- In the scheme, add a Send Signal node where the thing happens, and pick your asset in Signal. The field has a New button.
- In the scene, add Add Component > Intrigues > Signal Receiver to an object that stays active.
- Click Add Reaction and choose your asset in Signal.
- In Do This, add an action to the Unity event, for example the object to show and its
SetActivecall with the box checked. - Play the scene and run the scheme.
The reaction runs when the signal is sent.
What you will see
Section titled “What you will see”The receiver reads Listening for signals. Every reaction to the signal runs, from top to bottom.
The asset’s Inspector lists the nodes that send it under SENT BY and the receivers under LISTENERS IN OPEN SCENES. In Play mode, Send Now sends the signal by hand, and Run Now on a reaction card runs that reaction as if the signal had come. The card says how often it ran, or not run yet.
For a sound, the Play Sound node plays one straight from a scheme, with no receiver. Its Audience starts as Players Taking Part, so it plays only when a player takes part. A reaction can also call AudioSource.Play on a scene object, since Do This is a Unity event.
What can go wrong
Section titled “What can go wrong”- A reaction with no signal never runs. The card says so.
- The object is switched off. A receiver on an inactive object, or with its component off, does not listen. It can still switch another object on.
- A reaction switches off the receiver’s own object. After that the receiver stops listening. The card warns.
- The effect is gone after a load. Reactions are not saved, so send the signal again from On Game Loaded, as in Restore the scene after a load.
- An action fails. It is logged, the later actions of that reaction are skipped, and the other reactions still run.
- Send Signal with no signal chosen shows Sends nothing and an error.
How it connects
Section titled “How it connects”- The idea is on Signals, and the two Inspectors are on Signal and Signal Receiver.
- The nodes are Send Signal and Play Sound.
- Code can send and hear signals with
IM.SignalandIM.onSignalReceive, as Events reference shows.