How to link PrefabA and PrefabB in STYLY: step-by-step instructions for sending PlayMaker FSM actions as global events.

Using Unity and PlayMaker, here is a concrete implementation of sending global events from PrefabA and receiving them in PrefabB.

It is possible to upload PrefabA and PrefabB separately to STYLY, and then skip events (global events) from PlayMaker FSM actions executed in PrefabA to PrefabB.

Implementation Method

Prerequisites
・PlayMaker must be installed
・PrefabA and PrefabB must exist in the project and PlayMaker FSM must be attached to each.

Place the two Cubes in the hierarchy and rename the objects to PrafabA and PrafabB respectively.

Creating a global event

Open the Events tab on the PlayMaker Editor of PrefabA.

Create a global event by entering “TriggerEventB” in the Add Event section.

Image3

Send a global event from PrefabA

Configure the FSM attached to PrefabA to send an event.

Add a Send Event action to State1; in the Event Target setting, select “Broadcast All” to send the event to all FSMs; in the Send Event setting, select the TriggerEventB you just created for Event.

Image2

Receive global events in PrefabB

In the FSM attached to PrefabB, configure it to receive events and perform actions accordingly.

Create a new state State2 and right click > Add Global Transition > TriggerEventB.

Image1

Add the action you want to perform in State2, e.g. rotate an object using the “Rotate” action.

Image5

Run the project in Unity’s play mode and confirm that the TriggerEventB event skipped from PrefabA is received by PrefabB and executes the configured action (e.g. Rotate).

Image4

Finally, upload PrefabA and PrefabB to STYLY and place them in STYLY Studio to see if they actually work.