Yet another way to create nodes (or in this case rather implement the functionality of a node), is to implement such functionality within your own code by implementing the IExternalImplementedNode interface. Doing this will basically wrap up any functionality you want your type to have with respect to FlowCanvas, into a node. Here is an example of this:
1 2 3 4 5 6 7 8 |
public class Example : MonoBehaviour, FlowCanvas.Nodes.IExternalImplementedNode { void FlowCanvas.Nodes.IExternalImplementedNode.RegisterPorts(FlowCanvas.FlowNode parent) { var text = parent.AddValueInput("Text"); parent.AddFlowInput("Log Text", (f) => Debug.Log(text.value)); } } |
As you can see, the IExternalImplementedNode interface has only one method that needs implementation, that being the “RegisterPorts”. Registration here is the same as in Creating Full Nodes explained before, however doing it this way, you have direct access to all the methods, fields, properties etc of your type (which derives MonoBehaviour in this example) to get, set, call, or otherwise use!
When you drag and drop an instance of the “Example” MonoBehaviour we created above into a flowScript, on top of the usual options you will also be able to add the “Example” MonoBehaviour directly as an implemented node into the flowscript.
© Paradox Notion 2015-2024. All rights reserved.