Using the EventSystem
The EvenSystem consists of the Eventboard and the CallEvent and EventListener node.
Example
Create an Eventboard and Events
To create event you will need to create an Eventboard first.
Right click in the projects view and select Create / FlowReactor / New Eventboard.
Select the newly created eventboard and add your first event called “Say Hello”.
Assign the Eventboard
We now have to assign the Eventboard to our Graph.
Goto the properties view and select Events. You can now drag and drop the Eventboard asset file to the inspector. Events can now be called by using the CallEvent node.
Custom Parameters
Each event can have custom parameters. Inside of the Eventboard you can define parameters for each event. It is important to know that you are not assigning any parameter values in the Eventboard, you are only building the parameter “template”. Parameter values or arguments can be assigned in the CallEvent node when calling an actual event.
For our example lets add a string parameter to our “Say Hello” event.
Click on add parameter and select string.
Name it: Message
parameter values/arguments are assigned on the CallEvent node only. EventListener node on the other hand are retrieving the parameter values/arguments coming from the event.
Call an event
Let’s call our event with the custom parameter.
Create an OnStart node
Connect the OnStart node with a CallEvent node
Select the CallEvent node. You can now see all available events in the node inspector, select the “Say Hello” event.
Assign a text to the event parameter which you want to pass to. For example: “Hello”
Listen to an event
Now we need to add an EventListener node to actually listen to our event.
Add an EventListener node
Select the event “Say Hello” from the node inspector.
We now have to store the incoming event parameter value – which is the string variable: Message – to a global blackboard variable. So make sure you have created and assigned a blackboard to your graph with a string variable.
Now you can “connect” the event parameter “Message” to the blackboard string variable.
To see if our event gets called and if our event listen node is reacting to it. Connect a Debug.Log node to the EventListener node.
Connect the “Log” variable from the Debug.Log with the Blackboard variable.
Assign your graph to a FlowReactorComponent in the scene. Run the scene and you should see the debug.log output: “Hello” in the Unity console.
An EventListener node can also listen to local events only which are called inside of the same graph.
View all connected nodes
You can inspect all connected CallEvent and EventListener nodes for each event. Simply click on “Connected Nodes”. If the node exists in the current graph you can quickly navigate to it.
Last updated