Description
The PushUndo
method is a virtual method in the Editor.NodeEditor.GraphView
class. It is used to record the current state of the graph view, allowing changes to be undone. This method is typically called before making changes to the graph, ensuring that the user can revert to the previous state if needed.
Usage
To use the PushUndo
method, call it with a descriptive name for the undo action. This name will be used in the undo history to identify the action.
Example usage:
graphView.PushUndo("Add Node");
// Code to add a node to the graph
In this example, the action of adding a node is recorded with the name "Add Node". If the user decides to undo this action, they will see "Add Node" in the undo history.
Example
// Example of using PushUndo in a GraphView
public void AddNodeToGraph(GraphView graphView, NodeUI node)
{
// Record the current state before making changes
graphView.PushUndo("Add Node");
// Add the node to the graph
graphView.CreateNewNode(node);
}