# UndoBeginRecordGraph

> Signals the beginning of an undoable operation.

## Definition

* **Type:** Method
* **Namespace:** [Unity.GraphToolkit.Editor](/engine/6000.7/script-reference/unity/graphtoolkit/editor.md)
* **Assembly:** UnityEditor

## UndoBeginRecordGraph(string)

Signals the beginning of an undoable operation.

```csharp
public void UndoBeginRecordGraph(string actionName)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): 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](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graph/undoendrecordgraph.md) 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.

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

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the operation, which is displayed in the undo menu.**** (\[Node\[]]\(/engine/6000.7/script-reference/unity/graphtoolkit/editor/node)): 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](/engine/6000.7/script-reference/unity/graphtoolkit/editor/node.md) subclasses expose `[SerializeField]` fields that you mutate directly (for example, from a [NodeView\<T>](/engine/6000.7/script-reference/unity/graphtoolkit/editor/nodeview1.md) callback), rather than through the built-in graph modification methods.

Passing nodes here has two effects at [Graph.UndoEndRecordGraph](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graph/undoendrecordgraph.md) 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](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graph/ongraphchanged.md) and the graph asset is marked dirty.

The change-notification side effects ([Graph.OnGraphChanged](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graph/ongraphchanged.md) and automatic dirty-marking) run inside [Graph.UndoEndRecordGraph](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graph/undoendrecordgraph.md) 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](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graph/ongraphchanged.md) is not invoked and the asset is not automatically marked dirty. To persist your changes in that case, call [GraphDatabase.SaveGraph](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graphdatabase/savegraph.md) explicitly.

If you only call the built-in graph modification methods, use the parameterless [Graph.UndoBeginRecordGraph](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graph/undobeginrecordgraph.md) overload instead.
