Skip to main content

Creating Nodes

Learning how to create your own nodes is a crucial part of using Jungle. This guide will walk you through the process of creating a new node in each variant.


LEGO® Analogy

In a LEGO® set, each block is a small piece of a larger set. Each block is designed to be reused in as many sets as possible. The more versatile a block is, the more useful it is. The same goes for nodes. Each node should be a small piece of a larger task. Each node should be able to be used in as many trees as possible.

If a LEGO® block is too specific and only makes sense in a single set, it wouldn't be very useful. The same goes for nodes. Always make sure to split your tasks into separate, more modular and reusable nodes.

LEGO® is a trademark of the LEGO Group, which does not sponsor or endorse this site. LEGO references are purely illustrative.


Node Variants

Jungle has four node variants to choose from. Each variant has its own unique use case, but they all work the same way. Choosing the right variant for your node is very important. Below is a quick overview of each variant.

VariantDescription
Identity NodeA single input and a single output, except the input port type is defined by its connection.
IO NodeA single input and a single output.
Branch NodeA single input and multiple outputs.
Event NodeNo inputs but multiple outputs.

Using the Node Fabricator

Jungle comes with a tool for generating the boilerplate code for each node variant.

Node Fabricator

  • Step 1: Open the Node Fabricator window.

    • Right-click in the Assets window and select Create > Jungle Node.
  • Step 2: (Page 1) Set the properties for the node.

    • Title: The title of the node. This will be the class name. (Ex: "Hello World" becomes HelloWorldNode)
    • Description: A brief description of the node.
    • Category: The category of the node.
    • Color: The color of the node.
    • Icon: The icon of the node.
    • Methods: The methods to include in the generated script.
  • Step 3: (Page 2) Select the node variant you want to create.

  • Step 4: (Page 3) Set the properties for the selected node variant.

  • Step 5: Click the Create button to generate the node script.


Creating Nodes Manually

You can also create nodes manually if you prefer to do so. Below are the steps to create each node variant.

Identity Node

  • Step 1: Create a new C# script.

  • Step 2: Inherit the new class from the IdentityNode class.

using Jungle;

// ↓↓↓↓↓↓↓↓↓↓↓↓
public class MyIdentityNode : IdentityNode
{

}
  • Step 3: Implement the OnStart and OnUpdate method.
using Jungle;

public class MyIdentityNode : IdentityNode
{
// ↓↓↓↓↓↓↓
protected override void OnStart()
{

}

// ↓↓↓↓↓↓↓↓
protected override void OnUpdate()
{

}
}
  • Step 4: Add the IdentityNode attribute to the class.
    • tip

      If you don't want an output port, set the OutputPortName property null. (OutputPortName = null)

using Jungle;

// ↓↓↓↓↓↓↓↓↓↓
[IdentityNode(
InputPortName = "My Input",
OutputPortName = "My Output"
)]
public class MyIdentityNode : IdentityNode
{
protected override void OnStart()
{

}

protected override void OnUpdate()
{

}
}
  • Step 5: Add the NodeProperties attribute to the class.
using Jungle;

// ↓↓↓↓↓↓↓↓↓↓↓↓
[NodeProperties(
Title = "My Identity Node",
Description = "This is an identity node.",
Category = "My Nodes/Identity",
Color = Green
)]
[IdentityNode(
InputPortName = "My Input",
OutputPortName = "My Output"
)]
public class MyIdentityNode : IdentityNode
{
protected override void OnStart()
{

}

protected override void OnUpdate()
{

}
}

IO Node

  • Step 1: Create a new C# script.

  • Step 2: Inherit the new class from the IONode<T> class.

using Jungle;

// ↓↓↓↓↓↓
public class MyIONode : IONode<...>
{

}
  • Step 3: Set the accepted input port type in the angle brackets. (Ex: IONode<int>)
using Jungle;

// ↓↓↓↓↓↓↓↓↓↓
public class MyIONode : IONode<INPUT_TYPE>
{

}
  • Step 4: Implement the OnStart and OnUpdate method.
    • Ensure you include the input parameter in the OnStart method.
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 to the class.
    • tip

      If you don't want an output port, set the OutputPortName and OutputPortType property 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 to the class.
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()
{

}
}

Branch Node

  • Step 1: Create a new C# script.

  • Step 2: Inherit the new class from the BranchNode class.

using Jungle;

// ↓↓↓↓↓↓↓↓↓↓
public class MyBranchNode : BranchNode<...>
{

}
  • Step 3: Implement the OnStart and OnUpdate method.
    • Ensure you include the input parameter in the OnStart method.
using Jungle;

// ↓↓↓↓↓↓↓↓↓↓
public class MyBranchNode : BranchNode<INPUT_TYPE>
{
// ↓↓↓↓↓↓↓ ↓↓↓↓↓↓↓↓↓↓
protected override void OnStart(INPUT_TYPE inputValue)
{

}

// ↓↓↓↓↓↓↓↓
protected override void OnUpdate()
{

}
}
  • Step 4: Add the BranchNode attribute to the class.
    • tip

      If you don't want an output port, set the OutputPortName property null. (OutputPortName = null)

using Jungle;

// ↓↓↓↓↓↓↓↓
[BranchNode(
InputPortName = "My Input",
OutputPortNames = new []
{
"My Output 1",
"My Output 2"
},
OutputPortTypes = new []
{
typeof(OUTPUT_TYPE),
typeof(OUTPUT_TYPE)
}
)]
public class MyBranchNode : BranchNode<INPUT_TYPE>
{
protected override void OnStart(INPUT_TYPE inputValue)
{

}

protected override void OnUpdate()
{

}
}
  • Step 5: Add the NodeProperties attribute to the class.
using Jungle;

// ↓↓↓↓↓↓↓↓↓↓↓↓
[NodeProperties(
Title = "My Branch Node",
Description = "This is a Branch node.",
Category = "My Nodes/Branch",
Color = Green
)]
[BranchNode(
InputPortName = "My Input",
OutputPortNames = new []
{
"My Output 1",
"My Output 2"
},
OutputPortTypes = new []
{
typeof(OUTPUT_TYPE),
typeof(OUTPUT_TYPE)
}
)]
public class MyBranchNode : BranchNode<INPUT_TYPE>
{
protected override void OnStart(INPUT_TYPE inputValue)
{

}

protected override void OnUpdate()
{

}
}

Event Node

  • Step 1: Create a new C# script.

  • Step 2: Inherit the new class from the EventNode class.

using Jungle;

// ↓↓↓↓↓↓↓↓↓
public class MyEventNode : EventNode
{

}
  • Step 3: Implement the OnStart and OnUpdate method.
using Jungle;

public class MyEventNode : EventNode
{
// ↓↓↓↓↓↓↓
protected override void OnStart()
{

}

// ↓↓↓↓↓↓↓↓
protected override void OnUpdate()
{

}
}
  • Step 4: Add the EventNode attribute to the class.
using Jungle;

// ↓↓↓↓↓↓↓
[EventNode(
OutputPortNames = new []
{
"My Output 1",
"My Output 2"
},
OutputPortTypes = new []
{
typeof(OUTPUT_TYPE),
typeof(OUTPUT_TYPE)
}
)]
public class MyEventNode : EventNode
{
protected override void OnStart()
{

}

protected override void OnUpdate()
{

}
}
  • Step 5: Add the NodeProperties attribute to the class.
using Jungle;

// ↓↓↓↓↓↓↓↓↓↓↓↓
[NodeProperties(
Title = "My Event Node",
Description = "This is an Event node.",
Category = "My Nodes/Event",
Color = Green
)]
[EventNode(
OutputPortNames = new []
{
"My Output 1",
"My Output 2"
},
OutputPortTypes = new []
{
typeof(OUTPUT_TYPE),
typeof(OUTPUT_TYPE)
}
)]
public class MyEventNode : EventNode
{
protected override void OnStart()
{

}

protected override void OnUpdate()
{

}
}