Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

Graph.UndoBeginRecordGraph

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void UndoBeginRecordGraph(string actionName);

Parameters

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

Description

Signals the beginning of an undoable operation.

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.


Declaration

public void UndoBeginRecordGraph(string actionName, params Node[] nodesToRecord);

Parameters

Parameter Description
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.

Description

Signals the beginning of an undoable operation and opts specific nodes into full serialized-state capture.

Use this overload when your custom Node subclasses expose [SerializeField] fields that you mutate directly (for example, from a NodeView<T0> 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.