Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
EditorUndoRedoManager¶
Inherits: Object
Manages undo history of scenes opened in the editor.
Description¶
EditorUndoRedoManager is a manager for UndoRedo objects associated with edited scenes. Each scene has its own undo history and EditorUndoRedoManager ensures that each action performed in the editor gets associated with a proper scene. For actions not related to scenes (ProjectSettings edits, external resources, etc.), a separate global history is used.
The usage is mostly the same as UndoRedo. You create and commit actions and the manager automatically decides under-the-hood what scenes it belongs to. The scene is deduced based on the first operation in an action, using the object from the operation. The rules are as follows:
If the object is a Node, use the currently edited scene;
If the object is a built-in resource, use the scene from its path;
If the object is external resource or anything else, use global history.
This guessing can sometimes yield false results, so you can provide a custom context object when creating an action.
EditorUndoRedoManager is intended to be used by Godot editor plugins. You can obtain it using EditorPlugin.get_undo_redo. For non-editor uses or plugins that don't need to integrate with the editor's undo history, use UndoRedo instead.
The manager's API is mostly the same as in UndoRedo, so you can refer to its documentation for more examples. The main difference is that EditorUndoRedoManager uses object + method name for actions, instead of Callable.
Methods¶
void |
add_do_method ( Object object, StringName method, ... ) vararg |
void |
add_do_property ( Object object, StringName property, Variant value ) |
void |
add_do_reference ( Object object ) |
void |
add_undo_method ( Object object, StringName method, ... ) vararg |
void |
add_undo_property ( Object object, StringName property, Variant value ) |
void |
add_undo_reference ( Object object ) |
void |
commit_action ( bool execute=true ) |
void |
create_action ( String name, MergeMode merge_mode=0, Object custom_context=null, bool backward_undo_ops=false ) |
get_history_undo_redo ( int id ) const |
|
get_object_history_id ( Object object ) const |
|
is_committing_action ( ) const |
Signals¶
history_changed ( )
Emitted when the list of actions in any history has changed, either when an action is committed or a history is cleared.
version_changed ( )
Emitted when the version of any history has changed as a result of undo or redo call.
Enumerations¶
enum SpecialHistory:
SpecialHistory GLOBAL_HISTORY = 0
Global history not associated with any scene, but with external resources etc.
SpecialHistory REMOTE_HISTORY = -9
History associated with remote inspector. Used when live editing a running project.
SpecialHistory INVALID_HISTORY = -99
Invalid "null" history. It's a special value, not associated with any object.