Convert Figma logo to code with AI

alelievr logoNodeGraphProcessor

Node graph editor framework focused on data processing using Unity UIElements and C# 4.6

2,262
375
2,262
63

Top Related Projects

Additional tools for Visual Effect Artists

3,266

Unity Node Editor: Lets you view and edit node graphs inside Unity

Quick Overview

NodeGraphProcessor is a Unity package that provides a flexible and customizable node graph framework. It allows developers to create and manipulate node-based systems within Unity, suitable for various applications such as visual scripting, shader graphs, or AI behavior trees.

Pros

  • Highly customizable and extensible node graph system
  • Supports both runtime and editor-time graph execution
  • Includes a powerful and intuitive graph editor interface
  • Offers good performance and optimization features

Cons

  • Steep learning curve for beginners
  • Limited documentation and examples
  • Requires Unity-specific knowledge to fully utilize
  • May have compatibility issues with certain Unity versions

Code Examples

  1. Creating a custom node:
[System.Serializable, NodeMenuItem("Custom/MyNode")]
public class MyNode : BaseNode
{
    [Input(name = "Input")]
    public float input;

    [Output(name = "Output")]
    public float output;

    public override string name => "My Custom Node";

    protected override void Process()
    {
        output = input * 2;
    }
}
  1. Creating a graph:
public class MyGraph : BaseGraph
{
    public override string name => "My Custom Graph";

    protected override void Initialize()
    {
        base.Initialize();
        // Add custom initialization logic here
    }
}
  1. Processing a graph:
public class GraphProcessor : MonoBehaviour
{
    public BaseGraph graph;

    void Update()
    {
        graph.ProcessGraph();
    }
}

Getting Started

  1. Install the NodeGraphProcessor package in your Unity project.
  2. Create a new graph asset: Right-click in the Project window > Create > NodeGraphProcessor > New Graph
  3. Open the graph editor window: Window > Node Graph Processor > Graph Editor
  4. Drag your graph asset into the editor window to start editing
  5. Create custom nodes by inheriting from BaseNode and add them to your graph
  6. Process the graph in your scripts using graph.ProcessGraph()

For more detailed instructions and advanced usage, refer to the project's documentation on GitHub.

Competitor Comparisons

Additional tools for Visual Effect Artists

Pros of VFXToolbox

  • Official Unity tool, ensuring compatibility and long-term support
  • Focused specifically on visual effects, providing specialized features
  • Integrated with Unity's Visual Effect Graph for seamless workflow

Cons of VFXToolbox

  • Limited to visual effects, less versatile for general node-based systems
  • May have a steeper learning curve for users not familiar with Unity's VFX ecosystem
  • Potentially less flexible for custom node implementations

Code Comparison

NodeGraphProcessor:

[System.Serializable, NodeMenuItem("Custom/Add")]
public class AddNode : BaseNode
{
    [Input(name = "A")] public float inputA;
    [Input(name = "B")] public float inputB;
    [Output(name = "Out")] public float output;
}

VFXToolbox:

public class CustomVFXOperator : VFXOperator
{
    public class InputProperties
    {
        public Vector3 input = Vector3.zero;
    }
    public class OutputProperties
    {
        public Vector3 output = Vector3.zero;
    }
}

Summary

While NodeGraphProcessor offers a more general-purpose node graph system, VFXToolbox is tailored specifically for visual effects in Unity. NodeGraphProcessor provides greater flexibility for custom node implementations, while VFXToolbox integrates seamlessly with Unity's Visual Effect Graph. The choice between the two depends on the specific requirements of the project and the developer's familiarity with Unity's VFX ecosystem.

3,266

Unity Node Editor: Lets you view and edit node graphs inside Unity

Pros of xNode

  • Simpler and more lightweight, making it easier to learn and integrate
  • More flexible node customization options
  • Better documentation and community support

Cons of xNode

  • Less feature-rich compared to NodeGraphProcessor
  • Limited built-in node types and functionality
  • May require more manual setup for complex graph systems

Code Comparison

xNode:

[Node.CreateNodeMenu("Example/Add")]
public class AddNode : Node {
    [Input] public float a;
    [Input] public float b;
    [Output] public float result;

    protected override void NodeFunction() {
        result = a + b;
    }
}

NodeGraphProcessor:

[System.Serializable, NodeMenuItem("Basic/Add")]
public class AddNode : BaseNode {
    [Input(name = "A")] public float inputA;
    [Input(name = "B")] public float inputB;
    [Output(name = "Result")] public float output;

    public override string name => "Add";

    protected override void Process() {
        output = inputA + inputB;
    }
}

Both repositories provide node-based graph systems for Unity, but they differ in complexity and feature sets. xNode is more straightforward and flexible, while NodeGraphProcessor offers more advanced features out of the box. The code comparison shows similar node creation approaches, with NodeGraphProcessor using a slightly more verbose syntax but providing additional built-in functionality.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

NodeGraphProcessor

Node graph editor framework focused on data processing using Unity UIElements, GraphView and C# 4.7

Discord Codacy Badge openupm

This node based solution provides a great C# API allowing you to implement conditional graphs, dependencies graphs, processing graphs and more.
image

Based on Unity's GraphView technology, NodeGraphProcessor is also very fast and works well with large graphs.
Performance

Simple and powerful C# node API to create new nodes and custom views.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GraphProcessor;
using System.Linq;

[System.Serializable, NodeMenuItem("Operations/Sub")] // Add the node in the node creation context menu
public class SubNode : BaseNode
{
    [Input(name = "A")]
    public float                inputA;
    [Input(name = "B")]
    public float                inputB;

    [Output(name = "Out")]
    public float				output;

    public override string		name => "Sub";

    // Called when the graph is process, process inputs and assign the result in output.
    protected override void Process()
    {
        output = inputA - inputB;
    }
}

Unity Compatible versions

This project requires at least Unity 2020.2 with a scripting runtime version of 4.x in player settings.
The current Unity version used for the project is 2020.2.0f1, if you want to install NodeGraphProcessor in an older unity project, you can install it via Open UPM (minimum version: Unity 2019.3).

Installation

Instructions

Install Manually

There are two ways to install this asset: you can use the Unity package manager or move the entire repo inside your Assets folder. To install using the package manager:

  • download this repo
  • inside the package manager click the '+' button at the bottom to add a package from disk
  • then select the package.json file located in Assets/NodeGraphProcessor
  • package is installed :)

Install via OpenUPM

The package is available on the openupm registry. It's recommended to install it via openupm-cli.

openupm add com.alelievr.node-graph-processor

Install via Git

Alternatively, you can use the git address feature in the package manager on the branch #upm, it only contains the package but it may be out of sync compared to master.

Note that you'll not have access to the examples provided in this repo because the package only include the core of NodeGraphProcessor.

Community

Join the NodeGraphProcessor Discord server!

Features

  • Node and Graph property serialization (as json)
  • Scriptable Object to store graph as a Unity asset.
  • Highly customizable and simple node and links API
  • Support multi-input into a container (multiple float into a list of float for example)
  • Graph processor which execute node's logic with a dependency order
  • Documented C# API to add new nodes / graphs
  • Exposed parameters that can be set per-asset to customize the graph processing from scripts or the inspector
  • Parameter set mode, you can now output data from thegraph using exposed parameters. Their values will be updated when the graph is processed
  • Search window to create new nodes
  • Colored groups
  • Node messages (small message with it's icon beside the node)
  • Stack Nodes
  • Relay nodes
  • Display additional settings in the inspector
  • Node creation menu on edge drop
  • Simplified edge connection compared to default GraphView (ShaderGraph and VFX Graph)
  • Multiple graph window workflow (copy/paste)
  • Vertical Ports
  • Sticky notes (requires Unity 2020.1)
  • Renamable nodes

More details are available in the Changelog

Documentation

API doc is available here: alelievr.github.io/NodeGraphProcessor

The user manual is hosted using Github Wiki.

Remaining to do

  • Investigate for ECS/Jobs integration
  • API to create the graph in C#
  • Subgraphs

For more details consult our Github Project page.

Projects made with NodeGraphProcessor

Mixture

image

Want to be in the made with list? Send a message to the issue #14

Gallery

Minimap

Relay nodes

Node connection menu

Node creation menu

Graph Parameters

Groups

Node Settings

Node Messages

Conditional Processing (in Example)

Stacks

Relay Node Packing

Node Inspector

Improved Edge Connection

Multi-Window support

Field Drawers (Thanks @TeorikDeli!)

Sticky Notes (2020.1 or more required)

image

Vertical Ports

image

Drag And Drop Objects

CreateNodeFromObject

Renamable nodes

Just add this bit of code in your Node script to make it renamable in the UI.

        public override bool	isRenamable => true;

RenamableNode