ProtectedconstructorOptionalisInternalConstructor: booleanGet the entire history of the Undo/Redo stack, containing both commands that can be undone and redone.
The key window associated with this UndoRedo object.
Returns the unique identifier for the command on top of the undo stack.
Set the undo stack pointer to a specific index in the history, undoing or redoing commands in between.
Cancels all active undo operations.
Resets the undo/redo stacks.
Clear a separators to allow grouping of commands.
Finalizes all current undo operations and generated UndoableCommand entries for active operations
that contain valid changes.
Generates diffs for any objects that were previously recorded using any of the Record* methods. The diff is
generated by comparing the state at the time record... API was called, compared to the current object state.
OptionalselectObjectsOnUndoRedo: boolean
Determines if the objects should be selected upon Undo/redo. For UIElements, this could refocus the element immediately, depending on the undo type. For Scene Objects and Components, this could update the selection in the KeyWindow. Defaults to true.
Creates a brand new scene object and begins a recordNewSceneObject operation on the newly created scene object. Both the creation and the initially recorded set of data will be recorded as a single undo/redo command. Generally you want to call this when creating a new scene object and immediately make some initial changes to it (such as adding component or modifying their properties).
Newly created scene object on which to initiate the record operation on.
The name of the undo command.
The callback that performs the change.
OptionalisGroupable: boolean
Determines if the command should be grouped with similar commands.
True when the new scene object undo operation was committed and retained.
The sceneObject must already be parented to its intended parent before calling this method.
Example
const newSceneObject = new SceneObject("MyNewObject");
newSceneObject.parent = parentSceneObject;
undoRedo.createUndoForNewSceneObject(newSceneObject, "Create MyNewObject with Renderable Component",
(sceneObject) => sceneObject.addComponent(Renderable));
If the callback returns false, the undo operation will be immediately reverted, if isGroupable is false.
Records the current state of the object. A diff is automatically generated after the callback has been invoked.
If a change is detected an UndoableCommand will be created.
The object being changed.
The name of the undo command.
The callback that performs the change.
If the callback returns false, the undo operation will be immediately reverted when isGroupable is false.
OptionalfieldPath: string
Name to the field which should be focused when performing the undo/redo operation.
OptionalisGroupable: boolean
Determines if the command should be grouped with similar commands.
True when an undo operation was committed and retained.
The object may not be a SceneObject. Changes to scene objects must be recorded through
scene object specific APIs such as createUndoForSceneObject.
Records the complete state of the provided SceneObject including changes to Component objects
assigned to the scene object. Optionally, all child objects can be recorded.
A diff is automatically generated after the callback has been invoked.
If a change is detected an UndoableCommand will be created.
Scene object.
The name of the undo command.
The callback that performs the change.
If the callback returns false, the undo operation will be immediately reverted when isGroupable is false.
OptionalisRecursive: boolean
Set to true to include changes to children of the sceneObject
OptionalisGroupable: boolean
Determines if the command should be grouped with similar commands.
True when an undo operation was committed and retained.
If you only modify basic SceneObject properties such as name or the transform values,
it's better to use the more lightweight createUndoForSceneObjectHeaders API instead.
Records the current state of the provided SceneObject headers.
A diff is automatically generated after the callback has been invoked.
If a change is detected an UndoableCommand will be created.
Scene object, or an Array of SceneObjects.
The name of the undo command.
The callback that performs the change.
OptionalisGroupable: boolean
Determines if the command should be grouped with similar commands.
The SceneObjectHeader only contains primary properties such as name, transform, active and
similar basal properties. All components of the sceneObject as well as child objects are ignored.
To track changes to Component or children use createUndoForSceneObject instead.
Use this API for performance critical situations.
Records the complete state of multiple scene objects and invokes one callback inside a grouped undo operation. If the callback returns false, every committed object change is immediately reverted and removed from history.
Scene objects to record.
Name of the grouped undo command.
Callback that performs all object changes.
OptionalisRecursive: boolean
Set to true to include child objects in each recorded state.
True when the grouped undo operation was committed and retained.
Inserts a separator so the next command will not be batched, even though batching criterias are fullfilled.
Loads the history that was previously stashed with stashHistory. If the history was never stashed, an empty history will be loaded. Clears the stash.
Removes a command from the undo/redo list, without executing it.
Identifier of the command returned by getTopCommandIdx().
Removes all the command registered to the current undo/redo group.
Creates a new undo/redo group. All new commands will be registered to this group. You may remove the group and all of its commands by calling popGroup().
For example you might require global editor-wide undo/redo operations, and also more specific ones like input in an input box. When the user is done with the input box you no longer require its undo operations and you may use groups to easily remove them.
Unique name for the group.
Creates a brand new scene object and begins a recordSceneObject operation on the newly created scene object. Both the creation and the initially recorded set of data will be recorded as a single undo/redo command. Generally you want to call this when creating a new scene object and immediately make some initial changes to it (such as adding component or modifying their properties).
Newly created scene object on which to initiate the record operation on.
OptionalisGroupable: boolean
Determines if the command should be grouped with similar commands.
Records the current state of the object, and generates a diff with a call to commitActiveOperations.
If a change is detected an UndoableCommand will be created.
Object to record the state of.
Path to the field which should be focused when performing the undo/redo operation
OptionalisGroupable: booleanOptionaldescription: stringThe object may not be a SceneObject. Changes to scene objects must be recorded through
scene object specific APIs such as recordSceneObject.
Records the complete state of the provided SceneObject including changes to Component objects assigned to the scene object. Optionally, all child objects can be recorded. A diff is generated with a call to commitActiveOperations. If a change is detected an UndoableCommand will be created.
Scene object to record.
Determines if the child objects will be recorded as well, otherwise just the provided object.
Optional description specifying the type of changes about to be made.
OptionalisGroupable: boolean
Determines if the command should be grouped with similar commands.
If you only modify basic SceneObject properties such as name or the transform values,
it's better to use the more lightweight recordSceneObjectHeader API instead.
Records the current state of the provided SceneObject header, and generates a diff with a call to commitActiveOperations. If a change is detected an UndoableCommand will be created.
Scene object to record the state of.
Name to the field which should be focused when performing the undo/redo operation.
Optionaldescription: string
Description of the undo command.
OptionalisGroupable: boolean
Determines if the command should be grouped with similar commands.
The SceneObjectHeader only contains primary properties such as name, transform, active and
similar basal properties. All components of the sceneObject as well as child objects are ignored.
To track changes to Component or children use recordSceneObject instead.
Records the current state of the provided SceneObject headers, and generates a diff with a call to commitActiveOperations. If a change is detected an UndoableCommand will be created.
Scene objects to record the state of.
Description of the undo command.
OptionalisGroupable: boolean
Determines if the command should be grouped with similar commands.
OptionalselectedObjects: SceneObject[]
The selected objects that will be selected again when the command is undone or redone. If null, sceneObjects will be used for this purpose instead.
The SceneObjectHeader only contains primary properties such as name, transform, active and
similar basal properties. All components of the sceneObject as well as child objects are ignored.
To track changes to Component or children use recordSceneObject instead.
Use this API for performance critical situations.
Executes the last command on the redo stack (last command we called undo on), re-applying its operation.
Stashes the current undo/redo history. The history can be recreated later using loadHistoryFromStash.
Executes the last command on the undo stack, undoing its operations.
StaticmakeA utility function to create a context name for an undo operation on any type of object.
StaticmakeA utitlity function to create a context name for an undo operation.
ReadonlyonInvoked when an active undo command was commited to an undo operation.
ReadonlyonEvent triggered when the top of redo or undo stack changed.
ReadonlyonEvent triggered when the undo/redo stack history is rewritten, e.g. by calling clear.
ReadonlyonEvent triggered when a new command is added to the undo stack.
ReadonlyonEvent triggered when the top of the undo stack changed.
ReadonlyonEvent triggered whenever a command is registered.
ReadonlyonEvent triggered whenever a command is undone.
ReadonlyonEvent triggered whenever a command is redone.
The UndoRedo class provides undo and redo operations for changes made on objects.
Objects should be recorded before a change is made. The system will record a snapshot of the operation when the record is created and calculate the difference in a call to commitActiveOperations. If a difference is detected, the system will automatically create and insert a UndoableCommand.
To create an undo for a scene object, use createUndoForSceneObject methods. To create an undo for a regular TypeScript object, use createUndoForObject methods.