Hello everyone,
First of all, we would like to thank you all for your feedback on Graph Toolkit (GTK). We have taken note of your suggestions and have worked to address as many of them as we could. It is important for us to understand your use cases in order to continue improving the framework.
As you know, GTK has been a module since Unity 6.4. With the alpha of Unity 6.5, we have introduced several exciting new features. Here is a list of the main improvements we have made:
Creating graphs by code
We have enabled API methods to create graphs by code. This can be helpful if, for example, you have a data flow and want to visualize it as a graph.
Here is a small example:
// Create a new graph based on a custom SandboxGraph class
var graph = GraphDatabase.CreateGraph<SandboxGraph>("Assets/Generated/mygraph.sbg");
// Create a variable of type int
var variable = graph.CreateVariable<int>("myInt");
var variableNode = graph.AddVariableNode(variable, Vector2.zero);
// Create a node based on a custom CustomNode class
var node = new CustomNode();
node.Position = new Vector2(200, 0);
graph.AddNode(node);
// Connect the nodes
graph.Connect(variableNode.GetOutputPort(0), node.GetInputPortByName("input"));
The result looks like this:
These graph creation methods can be batched as a single undo-able operation using the added Undo/Redo API calls.
Please have a look at the scripting documentation to learn more about how to build a graph using code.
Soon we will provide a sample in our Samples package to showcase a more complex use case.
Customization
Node Customization
We’ve enabled new node customization options such as modifying the title, subtitle, color, vertical ports, multi-line text (TextArea), etc.
The following example demonstrates modifying the title, the color, and the library location of a node. The node is also modified with a multi-line text field option:
[Serializable]
// The node attribute let's you change the category, the icon and the title of the node
[Node("Tests/Custom", "Assets/Icons/Math.png", "Customized")]
public class CustomNode : Node
{
protected override void OnDefineOptions(IOptionDefinitionContext context)
{
context.AddOption<string>("multi-line text").AsTextArea().Build();
}
protected override void OnDefinePorts(IPortDefinitionContext context)
{
context.AddInputPort<int>("input").Build();
context.AddOutputPort<int>("output").Build();
}
public override void OnEnable()
{
Subtitle = "This node has some customizations";
DefaultColor = Color.hotPink;
}
}
Here is the result:
We know that some of you have been asking for deep UI customization such as applying your own USS or direct access to the visual elements of a graph. Members of the team are currently investigating this so rest assured that this is part of our roadmap. We just kindly ask for your patience regarding this matter.
Data Type Customization
With the new DataTypeStyleMapper you can now modify how a type is displayed in your graph. In the following example, the icon and the color of the Sprite type have been changed.
[DataTypeStyleMapper(typeof(SandboxGraph))]
public class SandboxDataStyleMapper : DataTypeStyleMapper
{
public SandboxDataStyleMapper()
{
var icon = EditorGUIUtility.IconContent("Assets/Icons/Math.png").image as Texture2D;
var color = EditorGUIUtility.isProSkin ? Color.yellowGreen : Color.darkOliveGreen;
Register(typeof(Sprite), icon, color);
}
}
Support for collections
Support has been added for inspectors for Lists and Arrays. You can now dynamically change the size of a collection and update the value of each entry directly in the graph.
Also with regards to Blackboard variables, you now have access to a dropdown menu (Mode) that allows you to convert a simple variable into a list of the same type. However for this Mode to appear, you must have created a port that can support this type of collection.
The code for the CollectionNode looks like this:
[Serializable]
public class CollectionNode : Node
{
protected override void OnDefinePorts(IPortDefinitionContext context)
{
context.AddInputPort<List<int>>("input A").Build();
context.AddInputPort<string[]>("input B").Build();
context.AddOutputPort<Vector2[]>("output").Build();
}
}
Other QoL improvements
Finally we’ve enabled some other quality of life improvements that have been requested by the community. Here is a list of some of these features:
Getting variables in the order in which they appear in Blackboard
You have now access to the Graph.GetVariables(SortMethod.Display) API to retrieve variables in the order they appear in the Blackboard.
Node Options on Subgraphs
Similar to a standard node, Subgraph nodes can have Node Options that can be defined in the Graph.OnDefineSubgraphNodeOptions(IOptionDefinitionContext ctx) callback.
Input/Output without type
You can now define an input/output without a type for your Subgraph.
Note that Untyped ports have their own defined icon and color. These can’t be changed at the moment, but we’re looking into a clean way to use the DataStyleMapper to modify these in the future.
Here is an example of a graph using Untyped input and output:
The resultant Subgraph node appears like this (note that it has a node option like described above):
Feel free to check out the 6.5 release notes for a complete list of changes and bugs we’ve fixed.
A new version of our Samples package is planned to be released soon, where we’ll provide examples of how to use the new features listed above.
What’s next?
The team is now focused on implementing debugging and visual feedback features such as animations on wires and progress bars on nodes. Stay tuned for updates on these.
Thank you again for using GTK. As always, we look forward to hearing your feedback on these new changes.







