Undo
UndoSystem
new UndoSystem()
Creates a new UndoSystem
Property | Type | Description |
---|---|---|
history | Array of UndoEntry | |
index | number |
initEdit( aspects )
Starts an edit to the current project by saving the state of the provided aspects
Arguments:
aspects
: UndoAspects - Aspects to saveselection
: boolean (Optional)elements
: Array of OutlinerElement (Optional)outliner
: boolean (Optional) - Saves the entire outliner structure and hierarchy, including all groups. This is required when adding, or removing any elements, or changing their position in the outliner.group
: Group (Optional) - Saves an individual group, but not it's children or hierarchy positiontextures
: Array of Texture (Optional) - Textures to savetexture_order
: boolean (Optional)selected_texture
: boolean (Optional) - Save which texture is selectedsettings
: See types (Optional)uv_mode
: boolean (Optional)animations
: Array of _Animation (Optional)animation_controllers
: Array of AnimationController (Optional)keyframes
: Array of _Keyframe (Optional)display_slots
: Array of string (Optional)exploded_view
: boolean (Optional)
Returns: UndoEntry
finishEdit( action[, aspects] )
Finishes an edit by saving the state of the project after it was changed
Arguments:
action
: string - Description of the editaspects
: UndoAspects (Optional)selection
: boolean (Optional)elements
: Array of OutlinerElement (Optional)outliner
: boolean (Optional) - Saves the entire outliner structure and hierarchy, including all groups. This is required when adding, or removing any elements, or changing their position in the outliner.group
: Group (Optional) - Saves an individual group, but not it's children or hierarchy positiontextures
: Array of Texture (Optional) - Textures to savetexture_order
: boolean (Optional)selected_texture
: boolean (Optional) - Save which texture is selectedsettings
: See types (Optional)uv_mode
: boolean (Optional)animations
: Array of _Animation (Optional)animation_controllers
: Array of AnimationController (Optional)keyframes
: Array of _Keyframe (Optional)display_slots
: Array of string (Optional)exploded_view
: boolean (Optional)
Returns: UndoEntry
cancelEdit()
Cancels an event before it was finished and reset the project to the state before
addKeyframeCasualties( keyframes )
Add keyframes to the current edit that were indirectly removed by moving other keyframes to their position
Arguments:
keyframes
: Array of _Keyframe -
initSelection( [aspects] )
Starts a selection change in the current project
Arguments:
aspects
: UndoSelectionAspects (Optional) - Aspects to savetexture_selection
: boolean (Optional)
Returns: UndoEntry
finishSelection( action[, aspects] )
Finishes a selection change in the current project
Arguments:
action
: string - Description of the editaspects
: UndoSelectionAspects (Optional)texture_selection
: boolean (Optional)
Returns: UndoEntry
cancelSelection( [revert_changes] )
Cancel the selection changes
Arguments:
revert_changes
: boolean (Optional) - If true, the already tracked selection changes will be reverted to the state before initSelection
undo( [remote] )
Cancels an event before it was finished and reset the project to the state before
Arguments:
remote
: boolean (Optional)
redo( [remote] )
Redoes the latest edit
Arguments:
remote
: boolean (Optional)
amendEdit( form, callback )
Provides a menu to amend the latest edit with slightly changed values
Arguments:
form
: InputFormConfigcallback
: See types
closeAmendEditMenu()
Closes the amend edit menu
loadSave( save, reference[, mode] )
Loads a specific undo save
Arguments:
save
: UndoSave - The undo save to loadreference
: UndoSave - The current undo save for referencemode
:"session"
(Optional) - The load save modes
Undo
Global Variable
Type: UndoSystem
Blockbench's undo system of the current project to register edits to the project and switch between them
Example
Undo.initEdit({elements: []});
let new_cube = new Cube({name: 'kevin'}).init();
let other_cube = new Cube({name: 'lars'}).init();
Undo.finishEdit('Add new cubes', {elements: [new_cube, other_cube]});