- Home /
Custom data for undo/redo action?
I would like to add undo/redo support for custom actions that are undertaken when using my editor script. Here is some pseudo-code that hopefully describes what I am after:
void SomeCustomAction() {
CustomAction action = new CustomAction();
action.Run();
}
public class CustomAction {
int x;
int y;
public void Run() {
OnRun();
// Obviously incorrect:
UnityEditor.Undo.RegisterCustomAction(this);
}
void OnRun() {
// Do something with x and y
}
void OnUndo() {
// Reverse process
}
void OnRedo() {
// Un-reverse process
OnRun();
}
}
Is it possible to register custom action data with callback(s) to handle each stage of undo/redo?
If you use Scene undo - it stores everything (before you do the action) - is that not enough for what you are doing?
@whydoidoit Scene undo is way too slow for what I need.
How about writing/implementing your own undo memento pattern?
Your answer
Follow this Question
Related Questions
Can my EditorWindow intercept Undo Redo Keyboard commands? 0 Answers
Catch a unity undo/redo event. 2 Answers
unity not undoing transform changes? 1 Answer
How to record hideFlags for Undo/Redo 0 Answers
Editor undo generic collection C# 0 Answers