Helper to manage UndoRedo in the editor or custom tools.
    public class UndoRedo : Object

Helper to manage UndoRedo in the editor or custom tools. It works by storing calls to functions in both ‘do’ an ‘undo’ lists.

Common behavior is to create an action, then add do/undo calls to functions or property changes, then committing the action.

Inheritance Chain

Constructors

    public UndoRedo()

Methods

    public object AddDoMethod(Object @object, string method, params object[] args)

    public void AddDoProperty(Object @object, string property, object value)

Set a property with a custom value.

    public void AddDoReference(Object @object)

Add a ‘do’ reference 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.

    public object AddUndoMethod(Object @object, string method, params object[] args)

    public void AddUndoProperty(Object @object, string property, object value)

Undo setting of a property with a custom value.

    public void AddUndoReference(Object @object)

Add an ‘undo’ reference 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!).

    public void ClearHistory()

Clear the undo/redo history and associated references.

    public void CommitAction()

Commit the action. All ‘do’ methods/properties are called/set when this function is called.

    public void CreateAction(string name, MergeMode mergeMode = MergeMode.Disable)

Create a new action. After this is called, do all your calls to AddDoMethod(Godot.Object, string, params object[]), AddUndoMethod(Godot.Object, string, params object[]), AddDoProperty(Godot.Object, string, object) and AddUndoProperty(Godot.Object, string, object).

    public string GetCurrentActionName()

Get the name of the current action.

    public int GetVersion()

Get the version, each time a new action is committed, the version number of the UndoRedo is increased automatically.

This is useful mostly to check if something changed from a saved version.

    public void Redo()

    public void Undo()

Inner Types

MergeMode

Name Value Description
Disable 0  
Ends 1  
All 2  
Tags: