Skip to content

Less3Design/less3-force-graph

Repository files navigation

Warning

Project is currently in a weird transition state. Removing the force direction and focusing on just making it a clean simple node editor. The information below is out of date.

Frame 51

A scriptable object framework and node graph UI that lets you easily create complex branching trees of data.

Force Directed

Nodes are positioned automically using a force-direction algorithm.

Nodes can be pinned freezing them in place.

Recording.2024-10-12.112308.mp4

Scriptable Objects

A Graph object can contain Node and Connection objects that connect with each other to create a tree.

Inside the Graph object you define what sort of nodes and connection the class supports, and any connection rules between the two you require.

using Less3.ForceGraph;
public class GenerationGraph : ForceGraph
{
    public override List<(string, Type)> GraphNodeTypes()
    {
        return new List<(string, Type)>
        {
            ("GenNode" , typeof(GenerationNode))
        };
    }
    public override Dictionary<Type, List<(string, Type)>> GraphConnectionTypes()
    {
        return new Dictionary<Type, List<(string, Type)>>
        {
            {typeof(GenerationNode), new List<(string,Type)>() {
                ("Gen Connection", typeof(GenerationConnection))
            }}
        };
    }

    public override bool ValidateConnectionRequest(ForceNode from, ForceNode to, Type connectionType)
    {
        return true;// assume all connections are valid
    }
}

Connections and Nodes behave as simple scriptable objects you can fill with whatever data you need.

public class GenerationNode : ForceNode
{
    public float exampleData;
}

public class GenerationConnection : ForceConnection
{
    public float helloThere;
}

About

Force directed node graph for the Unity Editor

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages