reckfellENGINE

EditorUndoRedoManager

Manages undo history of scenes opened in the editor.

On this page
class EditorUndoRedoManagerReckfellSharpEditorInherits ReckfellObject

Manages undo history of scenes opened in the editor.

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 Entity, 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 Reckfell editor plugins. You can obtain it using EditorPlugin.GetUndoRedo. 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.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Methods17

AddDoMethod2 overloads
# AddDoMethod · 1/2
C#
public void AddDoMethod(ReckfellObject @object, StringName method, params Variant[] args);

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.

Parameters
NameTypeDefault
objectReckfellObject—
methodStringName—
argsVariant[]—
# AddDoMethod · 2/2
C#
public void AddDoMethod(ReckfellObject @object, StringName method, ReadOnlySpan<Variant> args);

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.

Parameters
NameTypeDefault
objectReckfellObject—
methodStringName—
argsReadOnlySpan<Variant>—
AddDoPropertyvoid
# AddDoProperty
C#
public void AddDoProperty(ReckfellObject @object, StringName property, Variant value);

Register a property value change for "do". If this is the first operation, the object will be used to deduce target undo history.

Parameters
NameTypeDefault
objectReckfellObject—
propertyStringName—
valueVariant—
AddDoReferencevoid
# AddDoReference
C#
public void AddDoReference(ReckfellObject @object);

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.

Parameters
NameTypeDefault
objectReckfellObject—
AddUndoMethod2 overloads
# AddUndoMethod · 1/2
C#
public void AddUndoMethod(ReckfellObject @object, StringName method, params Variant[] args);

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.

Parameters
NameTypeDefault
objectReckfellObject—
methodStringName—
argsVariant[]—
# AddUndoMethod · 2/2
C#
public void AddUndoMethod(ReckfellObject @object, StringName method, ReadOnlySpan<Variant> args);

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.

Parameters
NameTypeDefault
objectReckfellObject—
methodStringName—
argsReadOnlySpan<Variant>—
AddUndoPropertyvoid
# AddUndoProperty
C#
public void AddUndoProperty(ReckfellObject @object, StringName property, Variant value);

Register a property value change for "undo". If this is the first operation, the object will be used to deduce target undo history.

Parameters
NameTypeDefault
objectReckfellObject—
propertyStringName—
valueVariant—
AddUndoReferencevoid
# AddUndoReference
C#
public void AddUndoReference(ReckfellObject @object);

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!).

Parameters
NameTypeDefault
objectReckfellObject—
ClearHistoryvoid
# ClearHistory
C#
public void ClearHistory(int id = -99, bool increaseVersion = true);

Clears the given undo history. You can clear history for a specific scene, global history, or for all histories at once (except EditorUndoRedoManager.SpecialHistory.RemoteHistory) if id is EditorUndoRedoManager.SpecialHistory.InvalidHistory. 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.

Note: If you want to mark an edited scene as unsaved without clearing its history, use EditorInterface.MarkSceneAsUnsaved instead.

Parameters
NameTypeDefault
idint-99
increaseVersionbooltrue
CommitActionvoid
# CommitAction
C#
public void CommitAction(bool execute = true);

Commits the action. If execute is true (default), all "do" methods/properties are called/set when this function is called.

Parameters
NameTypeDefault
executebooltrue
CreateAction3 overloads
# CreateAction · 1/3
C#
public void CreateAction(string name, UndoRedo.MergeMode mergeMode, ReckfellObject customContext);

Create a new action. After this is called, do all your calls to EditorUndoRedoManager.AddDoMethod, EditorUndoRedoManager.AddUndoMethod, EditorUndoRedoManager.AddDoProperty, and EditorUndoRedoManager.AddUndoProperty, then commit the action with EditorUndoRedoManager.CommitAction. 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.

Parameters
NameTypeDefault
namestring—
mergeModeUndoRedo.MergeMode—
customContextReckfellObject—
# CreateAction · 2/3
C#
public void CreateAction(string name, UndoRedo.MergeMode mergeMode, ReckfellObject customContext, bool backwardUndoOps);

Create a new action. After this is called, do all your calls to EditorUndoRedoManager.AddDoMethod, EditorUndoRedoManager.AddUndoMethod, EditorUndoRedoManager.AddDoProperty, and EditorUndoRedoManager.AddUndoProperty, then commit the action with EditorUndoRedoManager.CommitAction. 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.

Parameters
NameTypeDefault
namestring—
mergeModeUndoRedo.MergeMode—
customContextReckfellObject—
backwardUndoOpsbool—
# CreateAction · 3/3
C#
public void CreateAction(string name, UndoRedo.MergeMode mergeMode = UndoRedo.MergeMode.Disable, ReckfellObject customContext = null, bool backwardUndoOps = false, bool markUnsaved = true);

Create a new action. After this is called, do all your calls to EditorUndoRedoManager.AddDoMethod, EditorUndoRedoManager.AddUndoMethod, EditorUndoRedoManager.AddDoProperty, and EditorUndoRedoManager.AddUndoProperty, then commit the action with EditorUndoRedoManager.CommitAction. 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.

Parameters
NameTypeDefault
namestring—
mergeModeUndoRedo.MergeModeUndoRedo.MergeMode.Disable
customContextReckfellObjectnull
backwardUndoOpsboolfalse
markUnsavedbooltrue
ForceFixedHistoryvoid
# ForceFixedHistory
C#
public void ForceFixedHistory();

Forces the next operation (e.g. EditorUndoRedoManager.AddDoMethod) 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 EditorUndoRedoManager.CreateAction is sufficient.

GetHistoryUndoRedoUndoRedo
# GetHistoryUndoRedo
C#
public UndoRedo GetHistoryUndoRedo(int id);

Returns the 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 EditorUndoRedoManager.SpecialHistory). Best used with EditorUndoRedoManager.GetObjectHistoryId. 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).

Parameters
NameTypeDefault
idint—
Returns UndoRedo
GetObjectHistoryIdint
# GetObjectHistoryId
C#
public int GetObjectHistoryId(ReckfellObject @object);

Returns the history ID deduced from the given object. It can be used with EditorUndoRedoManager.GetHistoryUndoRedo.

Parameters
NameTypeDefault
objectReckfellObject—
Returns int
IsCommittingActionbool
# IsCommittingAction
C#
public bool IsCommittingAction();

Returns true if the EditorUndoRedoManager is currently committing the action, i.e. running its "do" method or property change (see EditorUndoRedoManager.CommitAction).

Returns bool

Signals and events2

HistoryChangedEvent
# HistoryChanged
C#
public event Action HistoryChanged;

Emitted when the list of actions in any history has changed, either when an action is committed or a history is cleared.

VersionChangedEvent
# VersionChanged
C#
public event Action VersionChanged;

Emitted when the version of any history has changed as a result of undo or redo call.

EditorUndoRedoManager.SpecialHistory

ValueDescription
GlobalHistory = 0

Global history not associated with any scene, but with external resources etc.

InvalidHistory = -99

Invalid "null" history. It's a special value, not associated with any object.

RemoteHistory = -9

History associated with remote inspector. Used when live editing a running project.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.