ISceneUndoScope UndoScope( string name )

robot_2Generated
code_blocksInput

Description

The UndoScope method in the HammerSceneEditorSession class is used to create a scope for undo operations within the Hammer Scene Editor. This method is particularly useful for grouping a series of changes into a single undoable action, allowing users to revert multiple changes with a single undo command.

This method returns an ISceneUndoScope object, which represents the scope of the undo operation. The scope is automatically closed when the returned object is disposed, ensuring that all changes made within the scope are captured as a single undoable action.

The method is virtual and sealed, meaning it can be overridden in derived classes but cannot be further sealed by those derived classes.

Usage

To use the UndoScope method, call it with a descriptive name for the undo action. This name will be displayed in the undo history, helping users understand what changes will be reverted when they perform an undo operation.

Example usage:

using (var undoScope = session.UndoScope("Move Objects"))
{
    // Perform operations that should be grouped into a single undo action
    MoveObject(object1, newPosition1);
    MoveObject(object2, newPosition2);
    // The scope will automatically close and register the undo action when disposed
}

Ensure that the operations you want to be undoable are performed within the using block. Once the block is exited, the undo action is finalized.

Example

using (var undoScope = session.UndoScope("Move Objects"))
{
    // Perform operations that should be grouped into a single undo action
    MoveObject(object1, newPosition1);
    MoveObject(object2, newPosition2);
    // The scope will automatically close and register the undo action when disposed
}