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:
// Namespace
using FlowReactor.Nodes.Modules
public class ControllableExample : MonoBehaviour, INodeControllable
{
// Gets called on node initialization
public void OnNodeInitialize(Node _node)
{
Debug.Log("On Initialization");
}
// Gets called on node execution
public void OnNodeExecute()
{
Debug.Log("On Execute");
}
// Gets called on node stop execution
public void OnNodeStopExecute()
{
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);
public void OnNode(Node _node, object[] _parameters){}
}
//
INodeControllable interface
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FlowReactor;
namespace FlowReactor.Nodes.Modules
{
public interface INodeControllable
{
// Automatically called on node initialization
void OnNodeInitialize(Node _node);
// Automatically called on node execution
void OnNodeExecute();
// Automatically called on node stop execution
void OnNodeStopExecute();
// Method for manual controllable method calls
void OnNode(Node _node, params object[] _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:
// Namespace
using FlowReactor.Nodes.Modules;
// Create new instance of type FRNodeControllable
FRNodeControllable moduleNodeControllable = new FRNodeControllable();
Then you can execute the methods in your custom node: