The UndoScope
method in the SceneEditorSession
class is used to create a scope for undo operations within the scene editor. This method returns an ISceneUndoScope
object, which represents a transactional scope for undo operations. This allows changes made within the scope to be undone as a single operation, providing a more manageable and organized way to handle undo functionality in the scene editor.
To use the UndoScope
method, call it with a descriptive name for the undo operation. This name will be used to identify the operation in the undo stack. The method returns an ISceneUndoScope
object, which should be disposed of after the operations are complete to ensure the scope is properly closed and the changes are committed to the undo stack.
Example usage:
using (var undoScope = sceneEditorSession.UndoScope("Move Objects"))
{
// Perform operations that should be grouped into a single undo action
MoveSelectedObjects();
RotateSelectedObjects();
ScaleSelectedObjects();
}
In this example, moving, rotating, and scaling objects are grouped into a single undo action named "Move Objects". When the undoScope
is disposed, the changes are committed to the undo stack.