:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/EditorUndoRedoManager.xml. .. _class_EditorUndoRedoManager: EditorUndoRedoManager ===================== **Hereda:** :ref:`Object` Manages undo history of scenes opened in the editor. .. rst-class:: classref-introduction-group Descripción ---------------------- **EditorUndoRedoManager** is a manager for :ref:`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 (:ref:`ProjectSettings` edits, external resources, etc.), a separate global history is used. The usage is mostly the same as :ref:`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 :ref:`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 :ref:`EditorPlugin.get_undo_redo()`. For non-editor uses or plugins that don't need to integrate with the editor's undo history, use :ref:`UndoRedo` instead. The manager's API is mostly the same as in :ref:`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 :ref:`Callable`. .. rst-class:: classref-reftable-group Métodos -------------- .. table:: :widths: auto +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_do_method`\ (\ object\: :ref:`Object`, method\: :ref:`StringName`, ...\ ) |vararg| | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_do_property`\ (\ object\: :ref:`Object`, property\: :ref:`StringName`, value\: :ref:`Variant`\ ) | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_do_reference`\ (\ object\: :ref:`Object`\ ) | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_undo_method`\ (\ object\: :ref:`Object`, method\: :ref:`StringName`, ...\ ) |vararg| | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_undo_property`\ (\ object\: :ref:`Object`, property\: :ref:`StringName`, value\: :ref:`Variant`\ ) | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_undo_reference`\ (\ object\: :ref:`Object`\ ) | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`clear_history`\ (\ id\: :ref:`int` = -99, increase_version\: :ref:`bool` = true\ ) | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`commit_action`\ (\ execute\: :ref:`bool` = true\ ) | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`create_action`\ (\ name\: :ref:`String`, merge_mode\: :ref:`MergeMode` = 0, custom_context\: :ref:`Object` = null, backward_undo_ops\: :ref:`bool` = false, mark_unsaved\: :ref:`bool` = true\ ) | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`force_fixed_history`\ (\ ) | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`UndoRedo` | :ref:`get_history_undo_redo`\ (\ id\: :ref:`int`\ ) |const| | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_object_history_id`\ (\ object\: :ref:`Object`\ ) |const| | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_committing_action`\ (\ ) |const| | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Señales -------------- .. _class_EditorUndoRedoManager_signal_history_changed: .. rst-class:: classref-signal **history_changed**\ (\ ) :ref:`🔗` Emitted when the list of actions in any history has changed, either when an action is committed or a history is cleared. .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_signal_version_changed: .. rst-class:: classref-signal **version_changed**\ (\ ) :ref:`🔗` Emitted when the version of any history has changed as a result of undo or redo call. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Enumeraciones -------------------------- .. _enum_EditorUndoRedoManager_SpecialHistory: .. rst-class:: classref-enumeration enum **SpecialHistory**: :ref:`🔗` .. _class_EditorUndoRedoManager_constant_GLOBAL_HISTORY: .. rst-class:: classref-enumeration-constant :ref:`SpecialHistory` **GLOBAL_HISTORY** = ``0`` Global history not associated with any scene, but with external resources etc. .. _class_EditorUndoRedoManager_constant_REMOTE_HISTORY: .. rst-class:: classref-enumeration-constant :ref:`SpecialHistory` **REMOTE_HISTORY** = ``-9`` History associated with remote inspector. Used when live editing a running project. .. _class_EditorUndoRedoManager_constant_INVALID_HISTORY: .. rst-class:: classref-enumeration-constant :ref:`SpecialHistory` **INVALID_HISTORY** = ``-99`` Invalid "null" history. It's a special value, not associated with any object. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Descripciones de Métodos ------------------------------------------------ .. _class_EditorUndoRedoManager_method_add_do_method: .. rst-class:: classref-method |void| **add_do_method**\ (\ object\: :ref:`Object`, method\: :ref:`StringName`, ...\ ) |vararg| :ref:`🔗` Register a method that will be called when the action is committed (i.e. the "do" action). If this is the first operation, the ``object`` will be used to deduce target undo history. .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_method_add_do_property: .. rst-class:: classref-method |void| **add_do_property**\ (\ object\: :ref:`Object`, property\: :ref:`StringName`, value\: :ref:`Variant`\ ) :ref:`🔗` Register a property value change for "do". If this is the first operation, the ``object`` will be used to deduce target undo history. .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_method_add_do_reference: .. rst-class:: classref-method |void| **add_do_reference**\ (\ object\: :ref:`Object`\ ) :ref:`🔗` Registra una referencia para "hacer" que se borrará si se pierde la historia de "hacer". Esto es útil sobre todo para los nuevos nodos creados para la llamada "hacer". No lo utilices para los recursos. .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_method_add_undo_method: .. rst-class:: classref-method |void| **add_undo_method**\ (\ object\: :ref:`Object`, method\: :ref:`StringName`, ...\ ) |vararg| :ref:`🔗` Register a method that will be called when the action is undone (i.e. the "undo" action). If this is the first operation, the ``object`` will be used to deduce target undo history. .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_method_add_undo_property: .. rst-class:: classref-method |void| **add_undo_property**\ (\ object\: :ref:`Object`, property\: :ref:`StringName`, value\: :ref:`Variant`\ ) :ref:`🔗` Register a property value change for "undo". If this is the first operation, the ``object`` will be used to deduce target undo history. .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_method_add_undo_reference: .. rst-class:: classref-method |void| **add_undo_reference**\ (\ object\: :ref:`Object`\ ) :ref:`🔗` Registra una referencia para "deshacer" que se borrará si se pierde la historia de "deshacer". Esto es útil sobre todo para los nodos eliminados con la llamada "hacer" (¡no la llamada "deshacer"!). .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_method_clear_history: .. rst-class:: classref-method |void| **clear_history**\ (\ id\: :ref:`int` = -99, increase_version\: :ref:`bool` = true\ ) :ref:`🔗` Clears the given undo history. You can clear history for a specific scene, global history, or for all scenes at once if ``id`` is :ref:`INVALID_HISTORY`. If ``increase_version`` is ``true``, the undo history version will be increased, marking it as unsaved. Useful for operations that modify the scene, but don't support undo. :: var scene_root = EditorInterface.get_edited_scene_root() var undo_redo = EditorInterface.get_editor_undo_redo() undo_redo.clear_history(undo_redo.get_object_history_id(scene_root)) \ **Note:** If you want to mark an edited scene as unsaved without clearing its history, use :ref:`EditorInterface.mark_scene_as_unsaved()` instead. .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_method_commit_action: .. rst-class:: classref-method |void| **commit_action**\ (\ execute\: :ref:`bool` = true\ ) :ref:`🔗` Commits the action. If ``execute`` is ``true`` (default), all "do" methods/properties are called/set when this function is called. .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_method_create_action: .. rst-class:: classref-method |void| **create_action**\ (\ name\: :ref:`String`, merge_mode\: :ref:`MergeMode` = 0, custom_context\: :ref:`Object` = null, backward_undo_ops\: :ref:`bool` = false, mark_unsaved\: :ref:`bool` = true\ ) :ref:`🔗` Create a new action. After this is called, do all your calls to :ref:`add_do_method()`, :ref:`add_undo_method()`, :ref:`add_do_property()`, and :ref:`add_undo_property()`, then commit the action with :ref:`commit_action()`. The way actions are merged is dictated by the ``merge_mode`` argument. If ``custom_context`` object is provided, it will be used for deducing target history (instead of using the first operation). The way undo operation are ordered in actions is dictated by ``backward_undo_ops``. When ``backward_undo_ops`` is ``false`` undo option are ordered in the same order they were added. Which means the first operation to be added will be the first to be undone. If ``mark_unsaved`` is ``false``, the action will not mark the history as unsaved. This is useful for example for actions that change a selection, or a setting that will be saved automatically. Otherwise, this should be left to ``true`` if the action requires saving by the user or if it can cause data loss when left unsaved. .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_method_force_fixed_history: .. rst-class:: classref-method |void| **force_fixed_history**\ (\ ) :ref:`🔗` Forces the next operation (e.g. :ref:`add_do_method()`) to use the action's history rather than guessing it from the object. This is sometimes needed when a history can't be correctly determined, like for a nested resource that doesn't have a path yet. This method should only be used when absolutely necessary, otherwise it might cause invalid history state. For most of complex cases, the ``custom_context`` parameter of :ref:`create_action()` is sufficient. .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_method_get_history_undo_redo: .. rst-class:: classref-method :ref:`UndoRedo` **get_history_undo_redo**\ (\ id\: :ref:`int`\ ) |const| :ref:`🔗` Returns the :ref:`UndoRedo` object associated with the given history ``id``. \ ``id`` above ``0`` are mapped to the opened scene tabs (but it doesn't match their order). ``id`` of ``0`` or lower have special meaning (see :ref:`SpecialHistory`). Best used with :ref:`get_object_history_id()`. This method is only provided in case you need some more advanced methods of :ref:`UndoRedo` (but keep in mind that directly operating on the :ref:`UndoRedo` object might affect editor's stability). .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_method_get_object_history_id: .. rst-class:: classref-method :ref:`int` **get_object_history_id**\ (\ object\: :ref:`Object`\ ) |const| :ref:`🔗` Returns the history ID deduced from the given ``object``. It can be used with :ref:`get_history_undo_redo()`. .. rst-class:: classref-item-separator ---- .. _class_EditorUndoRedoManager_method_is_committing_action: .. rst-class:: classref-method :ref:`bool` **is_committing_action**\ (\ ) |const| :ref:`🔗` Returns ``true`` if the **EditorUndoRedoManager** is currently committing the action, i.e. running its "do" method or property change (see :ref:`commit_action()`). .. |virtual| replace:: :abbr:`virtual (Normalmente, este método debería ser sobreescrito por el usuario para que tenga algún efecto.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (Este método no tiene efectos secundarios. No modifica ninguna de las variables miembro de la instancia.)` .. |vararg| replace:: :abbr:`vararg (Este método permite agregar cualquier número de argumentos después de los descritos aquí.)` .. |constructor| replace:: :abbr:`constructor (Este método se utiliza para construir un tipo.)` .. |static| replace:: :abbr:`static (Este método no necesita una instancia para ser llamado, por lo que puede llamarse directamente utilizando el nombre de la clase.)` .. |operator| replace:: :abbr:`operator (Este método describe un operador válido para usar con este tipo como operando izquierdo.)` .. |bitfield| replace:: :abbr:`BitField (Este valor es un entero compuesto como una máscara de bits de las siguientes banderas.)` .. |void| replace:: :abbr:`void (Sin valor de retorno.)`