Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


UndoBeginRecordGraph

Signals the beginning of an undoable operation.
Read time 2 minutesLast updated 13 days ago

Definition

UndoBeginRecordGraph(string)

Signals the beginning of an undoable operation.
public void UndoBeginRecordGraph(string actionName)

Parameters

actionName

The name of the operation, which is displayed in the undo menu.

Remarks

Call this before you trigger a sequence of graph modification methods to record those operations to the undo stack. Call Graph.UndoEndRecordGraph after the sequence to signal that the operation is complete.
Throws
InvalidOperationException
if there is no undo operation currently registered to the Graph.

UndoBeginRecordGraph(string, Node[])

Signals the beginning of an undoable operation and opts specific nodes into full serialized-state capture.
public void UndoBeginRecordGraph(string actionName, params Node[] nodesToRecord)

Parameters

actionName

The name of the operation, which is displayed in the undo menu.

nodesToRecord

The nodes whose serialized state you plan to mutate inside this scope. Each node must belong to this graph.

Remarks

Use this overload when your custom Node subclasses expose
[SerializeField]
fields that you mutate directly (for example, from a NodeView<T> callback), rather than through the built-in graph modification methods.
Passing nodes here has two effects at Graph.UndoEndRecordGraph time:
Unity's undo system captures the full serialized state of the containing graph asset at Begin, so undo restores the previous values of your
[SerializeField]
fields.
The nodes are reported as changed to Graph.OnGraphChanged and the graph asset is marked dirty.
The change-notification side effects (Graph.OnGraphChanged and automatic dirty-marking) run inside Graph.UndoEndRecordGraph only when the graph is currently being displayed in a GraphView window. From an editor script or other headless context with no open window, undo capture via
Undo.RegisterCompleteObjectUndo
still occurs and undo restores your
[SerializeField]
values as expected, but Graph.OnGraphChanged is not invoked and the asset is not automatically marked dirty. To persist your changes in that case, call GraphDatabase.SaveGraph explicitly.
If you only call the built-in graph modification methods, use the parameterless Graph.UndoBeginRecordGraph overload instead.