IO Nodes (Manually)
This guide will walk you through creating IO nodes in Jungle manually. Let's get started!
Step 1: Create a New C# Script
First, create a new C# script in your Unity project.
Step 2: Inherit from IONode<T>
Next, make your new class inherit from the IONode<T>
class.
This will form the foundation of your IO node.
using Jungle;
// ↓↓↓↓↓↓
public class MyIONode : IONode<...>
{
}
Step 3: Set the Input Port Type
Set the accepted input port type in the angle brackets.
For example, IONode<int>
.
using Jungle;
// ↓↓↓↓↓↓↓↓↓↓
public class MyIONode : IONode<INPUT_TYPE>
{
}
Step 4: Implement OnStart
and OnUpdate
Now, you need to implement the OnStart
and OnUpdate
methods.
Ensure the OnStart
method includes the input parameter.
using Jungle;
public class MyIONode : IONode<INPUT_TYPE>
{
// ↓↓↓↓↓↓↓ ↓↓↓↓↓↓↓↓↓↓
protected override void OnStart(INPUT_TYPE inputValue)
{
}
// ↓↓↓↓↓↓↓↓
protected override void OnUpdate()
{
}
}
Step 5: Add the IONode
Attribute
Add the IONode
attribute to your class.
This defines the input and output ports.
If you don't want an output port, set the OutputPortName
and OutputPortType
properties to null.
(OutputPortName = null
and OutputPortType = null
)
using Jungle;
// ↓↓↓↓↓↓↓↓↓
[IONode(
InputPortName = "My Input",
OutputPortName = "My Output",
OutputPortType = typeof(OUTPUT_TYPE)
)]
public class MyIONode : IONode<INPUT_TYPE>
{
protected override void OnStart(INPUT_TYPE inputValue)
{
}
protected override void OnUpdate()
{
}
}
Step 6: Add the NodeProperties
Attribute
Finally, add the NodeProperties
attribute to your class.
This defines additional properties such as the title, description, and category of your node.
using Jungle;
// ↓↓↓↓↓↓↓↓↓↓↓↓
[NodeProperties(
Title = "My IO Node",
Description = "This is an IO node.",
Category = "My Nodes/IO",
Color = Green
)]
[IONode(
InputPortName = "My Input",
OutputPortName = "My Output",
OutputPortType = typeof(OUTPUT_TYPE)
)]
public class MyIONode : IONode<INPUT_TYPE>
{
protected override void OnStart(INPUT_TYPE inputValue)
{
}
protected override void OnUpdate()
{
}
}
With these steps, you've created a basic IO node in Jungle. Feel free to customize the input and output types and the properties to suit your needs!