ActionGraph — visual scripting with action nodes, delegates, and C# integration
ActionGraph — Visual Scripting
ActionGraph is s&box's visual scripting system. Nodes represent actions or expressions, and links carry values or signals between them. It's designed for designers and non-programmers, but integrates cleanly with C# components.
Node Types
Action nodes (blue) — have signal sockets (white arrows). They trigger when a signal arrives and fire an output signal when done. Most have one input and one output signal socket. Expression nodes (green) — no signal sockets. They compute a value from inputs and evaluate lazily when their output is consumed. Root node — the entry point of every graph. Cannot be deleted. Fires a signal when the graph runs.Control Flow
Special action nodes handle branching and loops:
- If — branches on a bool condition
- While — loops while a condition is true
- For Each — iterates a collection
- For Range — iterates a numeric range
Using ActionGraph with C#
Component Actions (No Code Required)
Add [ActionGraphNode] to a method to expose it as a node in ActionGraph:
public sealed class Door : Component
{
[ActionGraphNode( "Open Door" )]
public void Open()
{
// Called from ActionGraph
_isOpen = true;
}
}Delegate Properties
Expose an ActionGraph as a property on your component — designers wire it up in the inspector:
public sealed class Button : Component
{
// Designer wires up what happens when pressed
[Property] public Action OnPressed { get; set; }
protected override void OnUpdate()
{
if ( Input.Pressed( "Use" ) )
OnPressed?.Invoke();
}
}Passing Parameters
[Property] public Action<float> OnDamaged { get; set; }
public void TakeDamage( float amount )
{
OnDamaged?.Invoke( amount );
}Variables
Variables in ActionGraph are scoped to the graph instance. Create them in the Variables panel and use Get/Set nodes to read and write them. Use variables to avoid long-distance links cluttering the graph.
Custom C# Nodes
Mark a static method with [ActionGraphNode] in a non-component class to add it to the node creation menu:
public static class GameNodes
{
[ActionGraphNode( "Spawn Prefab At" )]
public static GameObject SpawnAt( GameObject prefab, Vector3 position )
{
return prefab.Clone( position );
}
}When to Use ActionGraph vs C#
- ActionGraph — event-driven logic, level scripting, designer-owned behaviour, rapid prototyping
- C# — performance-critical code, complex algorithms, reusable systems, anything with loops over many objects