The FRNodeControllable module allows you to control an external MonoBehaviour script in the scene – which implements the INodeControllable interface – from a node.
See the demo scene: NodeModules
Example
The simplest way of using this, is by adding the External Script Controller node to your graph.
FlowReactor then shows you all nodes which have the FRNodeControllable module added in the FlowRector Component.
Next create a new Monobehaviour script and add the INodeControllable interface to it like this:
// NamespaceusingFlowReactor.Nodes.ModulespublicclassControllableExample : MonoBehaviour, INodeControllable{ // Gets called on node initializationpublicvoidOnNodeInitialize(Node_node) {Debug.Log("OnInitialization"); } // Gets called on node executionpublicvoidOnNodeExecute() {Debug.Log("On Execute"); } // Gets called on node stop executionpublicvoidOnNodeStopExecute() {Debug.Log("On Stop Execute"); } // Method for manual controllable method calls // This requires that the node which has the FRControllableModule to // call the method: CallOnNode(_flowRector, this, null);publicvoidOnNode(Node _node,object[] _parameters){}}//
INodeControllable interface
usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;usingFlowReactor;namespaceFlowReactor.Nodes.Modules{publicinterfaceINodeControllable { // Automatically called on node initializationvoidOnNodeInitialize(Node _node); // Automatically called on node executionvoidOnNodeExecute(); // Automatically called on node stop executionvoidOnNodeStopExecute(); // Method for manual controllable method callsvoidOnNode(Node _node,paramsobject[] _parameters); }}//
Add FRNodeControllable to custom node
If you want to implement the FRNodeControllable or any other node module to a custom node, you simply have to create a new instance of the module like this:
// NamespaceusingFlowReactor.Nodes.Modules;// Create new instance of type FRNodeControllableFRNodeControllable moduleNodeControllable =newFRNodeControllable();
Then you can execute the methods in your custom node: