Manages undo history of scenes opened in the editor.
</brief_description>
<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.
</description>
<tutorials>
</tutorials>
<methods>
<methodname="add_do_method"qualifiers="vararg">
<returntype="void"/>
<paramindex="0"name="object"type="Object"/>
<paramindex="1"name="method"type="StringName"/>
<description>
Register a method that will be called when the action is committed (i.e. the "do" action).
If this is the first operation, the [param object] will be used to deduce target undo history.
</description>
</method>
<methodname="add_do_property">
<returntype="void"/>
<paramindex="0"name="object"type="Object"/>
<paramindex="1"name="property"type="StringName"/>
<paramindex="2"name="value"type="Variant"/>
<description>
Register a property value change for "do".
If this is the first operation, the [param object] will be used to deduce target undo history.
</description>
</method>
<methodname="add_do_reference">
<returntype="void"/>
<paramindex="0"name="object"type="Object"/>
<description>
Register a reference for "do" that will be erased if the "do" history is lost. This is useful mostly for new nodes created for the "do" call. Do not use for resources.
</description>
</method>
<methodname="add_undo_method"qualifiers="vararg">
<returntype="void"/>
<paramindex="0"name="object"type="Object"/>
<paramindex="1"name="method"type="StringName"/>
<description>
Register a method that will be called when the action is undone (i.e. the "undo" action).
If this is the first operation, the [param object] will be used to deduce target undo history.
</description>
</method>
<methodname="add_undo_property">
<returntype="void"/>
<paramindex="0"name="object"type="Object"/>
<paramindex="1"name="property"type="StringName"/>
<paramindex="2"name="value"type="Variant"/>
<description>
Register a property value change for "undo".
If this is the first operation, the [param object] will be used to deduce target undo history.
</description>
</method>
<methodname="add_undo_reference">
<returntype="void"/>
<paramindex="0"name="object"type="Object"/>
<description>
Register a reference for "undo" that will be erased if the "undo" history is lost. This is useful mostly for nodes removed with the "do" call (not the "undo" call!).
Create a new action. After this is called, do all your calls to [method add_do_method], [method add_undo_method], [method add_do_property], and [method add_undo_property], then commit the action with [method commit_action].
The way actions are merged is dictated by the [param merge_mode] argument. See [enum UndoRedo.MergeMode] for details.
If [param custom_context] object is provided, it will be used for deducing target history (instead of using the first operation).
Returns the [UndoRedo] object associated with the given history [param id].
[param id] above [code]0[/code] are mapped to the opened scene tabs (but it doesn't match their order). [param id] of [code]0[/code] or lower have special meaning (see [enum SpecialHistory]).
Best used with [method get_object_history_id]. This method is only provided in case you need some more advanced methods of [UndoRedo] (but keep in mind that directly operating on the [UndoRedo] object might affect editor's stability).
Returns [code]true[/code] if the [EditorUndoRedoManager] is currently committing the action, i.e. running its "do" method or property change (see [method commit_action]).