Documentation

Learn how to use FlowCanvas

Download PDF Version

Events

Event Nodes are responsible for beginning and triggering any Flow Execution. Without an Event node nothing will really happen in your flowscript. You add Event nodes to respond to world or object events and changes like Input, Triggers, Collisions etc. and finally connect their flow outputs to other nodes to designate what will happen when the event is triggered.

EventNode

Some Event Nodes require an object reference on which the event will take place. By default the target object will be “Self”, which corresponds to the gameobject on which the FlowScriptController component is attached to. You are though free to change the target object through the inspector by either assigning a new reference or linking a blackboard variable.

EventNodeInspector

Multiple Targets

All of the Event Nodes that are related to an object, like Trigger, Collision, Mouse etc, can optionally also work with multiple targets instead of only one. This option can be enabled in the Event Node inspector panel. When the “Target Mode” option is set to “Multiple Targets” instead of “Single Target”, then the node will work with a list of objects (of correct type), rather than a single object of such type. As such, the event will be fired when any of the targets fires that event.

Following is an example of using a Mouse Over event with multiple objects. Notice that as the cursor comes over the different spheres, the event is fired. The “This” output value of the node in this case, returns the current object for which the event is fired, or in other words and for this example, the sphere that the cursor is currently over.

MultiTargets

All Event nodes have a red title name, no inputs and any number of outputs in a mix of Flow and Value ports. Value ports of Event nodes, usually contain information about the event that has just been triggered.

Hooking Unity Events and C# Events

One of the very important and unique features of FlowCanvas, is the ability to create event nodes out of any UnityEvent or C# Event via reflection! When looking at the nodes of a type (Functions/Reflected/{TYPE}), or when for example you simply drag and drop a component like UISlider or UIButton in the canvas, depending on the type, it may have a list of it’s own events defined under the “Events” subcategory for the type, either a Unity Event, or a C# Event. FlowCanvas allows to hook up to those events via reflection and get a flow signal in a flowScript when that event is raised.

Lets for example take the UI Slider On Value Changed event. A Unity Event defined by the Slider class. To hook that event in a flowScript, we need to first get a reference to the event, which can for example be done by drag & drop a Slider from the hierarchy into the canvas and in the menu that will popup, selecting “Slider/Events/Get On Value Changed”. This will create a node that returns the Unity Event reference.

GetOnValueChange

The output of the event needs to go into a special FlowCanvas node, called “Unity Event Callback” and which can be found under “Events/Custom/Unity Event Callback”. With both the nodes in the canvas and simply connecting the slider event into the still “Wild” port definition of the “Unity Event Callback” node, we complete the necessary wiring. Notice that once this is done, the Unity Event Callback node will show a few extra ports.

HookEvent

Register input is required to be called to register the event.
Unregister input is required to be called to unregister the event.

Both of Register and Unregister, can also be handled automatically if you so required, simply by selecting the node and enabling “Auto Handle Registration” !

Regarding the output ports,

Callback is the port that will be called when the Slider event is raised.
ArgX is the argument. Depending on the event it may have more arguments than one. Slider in this case, only have one argument that being the new value that the slider has.

C# Events work exactly the same way, but instead of using “Unity Event Callback” node, the “C# Event Callback” node needs to be used!

Yes No Suggest edit
16 of 17 users found this section helpful
Suggest Edit