Loading...
Loading...
Builds node-based Editor tools with Unity Graph Toolkit (GTK) on Unity 6.6+: graphs, nodes, ports and validation, State Machine API tools on 6.7+, and runtime assets via a scripted importer. Use for custom graph, node or state machine editors, or migrating a GraphView tool. Not for Shader Graph, VFX Graph or Animator Controllers.
npx skill4agent add unity-technologies/skills build-gtkUnity.GraphToolkit.Editorreferences/graph-api.mdreferences/state-machine-api.mdreferences/runtime-and-visualization.mdreferences/pitfalls.mdm_EditorVersionProjectSettings/ProjectVersion.txtcom.unity.graphtoolkit| Editor version | What is available |
|---|---|
| Older than 6000.4 | Only the retired experimental package (0.x). Its API differs from this skill. Recommend upgrading. |
| 6000.4 to 6000.5 | Module present, but without port capacity, type casting, wire and node visualization, USS node styling, or element IDs. |
| 6000.6 | The Graph API this skill documents. |
| 6000.7 and newer | Everything above plus the State Machine API, |
GraphStateMachine[Graph("ext")][StateMachine("ext")][UseWithGraph][UseWithStateMachine][Serializable]Editor| Never write | Write instead |
|---|---|
| |
| |
| |
| the window is provided; |
| no equivalent; model the tool as |
| nothing; the module is built in |
references/graph-api.mdreferences/runtime-and-visualization.md[Graph(AssetExtension)] [Serializable] class MyGraph : Graphpublic const string AssetExtension[MenuItem("Assets/Create/...")]GraphDatabase.PromptInProjectBrowserToCreateNewAsset<MyGraph>()GraphOptions.SupportsSubgraphs[Serializable] class MyNode : NodeOnDefinePorts.Build()OnDefineOptionsOnDefinePortsGetNodeOptionByName(name).TryGetValue<T>(out var v).Delayed()[Node("Category/Path", iconPath, title, stylesheet)]OnGraphChanged(GraphLogger logger)logger.LogErrorLogWarningLogGraphLogActionIsConnectionAllowedgraph-api.mdScriptedImportervar graph = GraphDatabase.LoadGraphForImporter<MyGraph>(ctx.assetPath); // never LoadGraph here
if (graph == null) return; // bad path or type: log and stop
var start = graph.GetNodes().OfType<StartNode>().FirstOrDefault();
if (start == null) return; // OnGraphChanged already reported it
var next = start.GetOutputPortByName("Next").FirstConnectedPort?.GetNode(); // null when unconnected
var titlePort = next.GetInputPortByName("Title");
titlePort.TryGetValue<string>(out var title); // the value typed on the node
if (titlePort.IsConnected) { /* resolve titlePort.FirstConnectedPort.GetNode() upstream instead */ }
ctx.AddObjectToAsset("Runtime", runtime); ctx.SetMainObject(runtime);Unity.GraphToolkit.EditorHash128Hash128runtime-and-visualization.mdreferences/state-machine-api.md[StateMachine(AssetExtension)] [Serializable] class MySM : StateMachineStateMachineDatabase.PromptInProjectBrowserToCreateNewAsset<MySM>()[Serializable] class Patrol : StateOnDefineOptions[Serializable] [Condition("Health")] class HealthCondition : Condition<float>protected override bool DisplayComparisonDropdown => trueConditionSelfTransition[Transition(...)]StateView<T>ConditionView<T>[StateMachineMenu][ConditionMenu]OnStateMachineChanged(StateMachineLogger logger)OnGraphChangedScriptedImporterStateMachineDatabase.LoadStateMachineForImporter<MySM>GetStates()GetOutgoingTransitions()GetRules()RootConditionIGroupConditionOperationIVariableConditionVariable.NameComparisonValueCondition<T>LoadGraphCreateGraphUndoBeginRecordGraph("Action")AddNodeConnectport.TrySetValueCreateVariableGraphDatabase.SaveGraph(graph)UndoEndRecordGraph()UndoBeginRecordStateMachineConnect(fromState, toState)SaveStateMachineUndoEndRecordStateMachineOnEnableOnDisableOnGraphChangedOnStateMachineChangedInvalidOperationException| The user wants | Do this | Why |
|---|---|---|
| Limit how many wires a port accepts | | Ports default to multiple wires, so the framework enforces the limit only if you declare it |
Connect an | Override | Ports of different types refuse to connect by default; the graph only records the wire, your importer converts |
| One port that accepts several types, like Shader Graph | 6000.7+: | |
| An execution-flow port with no data type | | Flow ports carry no value; typing them invites wrong connections |
| Hide a node type from the Add menu | Make it | Every concrete node class in the graph's assembly is listed automatically |
| Group nodes in the Add menu | | The attribute's first argument is a folder path, not the node's title |
Know what changed, like the old | 6000.7+: | |
| Several kinds of subgraph | | Without the attribute the main graph type doubles as the only subgraph type |
| Ports on a subgraph node | Blackboard variables of kind | Subgraph nodes have no |
| Node icon or USS look | | The Editor picks the |
| Show which node runs and what flows through ports at runtime | GraphVisualization API, see | Graph Toolkit has no runtime; the game must push state back into the open window |
| An Animator-like state machine editor | Workflow B on 6000.7+. On 6000.6, explain it is not available | The State Machine API does not exist before 6000.7 |
| Extra UI inside a node | | |
FirstConnectedPortIsConnectedHash128Unity.GraphToolkit.Editor#if UNITY_EDITORreferences/pitfalls.mdDebug.Logreferences/pitfalls.mdWebFetchWebSearch<VERSION>docs.unity.com/en-us/engine/<VERSION>docs.unity3d.com/<VERSION>/DocumentationProjectSettings/ProjectVersion.txt6000.66000.7docs.unity3d.com/Packages/com.unity.graphtoolkit-samples@<VERSION>0.6https://docs.unity.com/en-us/engine/<VERSION>/.mdmanual/extending-the-editor/gtk-index.mdmanual/extending-the-editor/gtk-index/implementing-a-graph-tool.mdimplement-a-graph-tool.mdimplement-nodes.mdimplement-node-options.mdimplement-context-nodes.mdimplement-block-nodes.mdtype-cast-ports.mdadd-custom-toolbar-actions.mdadd-subgraph-support.mdgraph-processing.mdmanual/extending-the-editor/gtk-index/landing-graph-interface.mdgraph-window.mdblackboard.mdgraph-inspector.mdminimap.mdscript-reference/unity/graphtoolkit/editor/<type>.md.../<type>/<member>.mdcondition.mdCondition<T>script-reference/unity/graphtoolkit/editor/graph/ongraphchanged.md6000.7https://docs.unity3d.com/<VERSION>/Documentation/ScriptReference/Unity.GraphToolkit.Editor.<Type>.htmlhttps://docs.unity3d.com/Packages/com.unity.graphtoolkit-samples@<VERSION>/manual/index.htmlcom.unity.graphtoolkit-samples