Description
The AddUndo
method is used to register an undo action within the scene editor session. This method allows you to specify a name for the undo action, as well as the actions to perform for undoing and redoing the changes. This is particularly useful for maintaining a history of changes that can be reverted or reapplied, enhancing the user's ability to manage scene modifications effectively.
Usage
To use the AddUndo
method, you need to provide a descriptive name for the undo action, along with two System.Action
delegates that define the operations to be performed when the action is undone and redone. This method is sealed, meaning it cannot be overridden in derived classes.
Example
// Example of using AddUndo in a SceneEditorSession
SceneEditorSession session = new SceneEditorSession();
// Define undo and redo actions
System.Action undoAction = () => {
// Code to undo changes
};
System.Action redoAction = () => {
// Code to redo changes
};
// Add the undo action to the session
session.AddUndo("Move Object", undoAction, redoAction);