You could implement this with a stack of action objects.
-
You should create an Action class where you need to add three events: Execute, Undo and Redo.
-
Next, for any action you want to process, create a class inherited from the base Action class and add the necessary data there.
-
Override events: Execute, Undo and Redo in child class.
-
Create an array(stack) of Actions objects in another class where you want.
-
At runtime, add a child class object to the array for each action.
-
Next, you can move up and down the stack by triggering Undo and Redo events
In the same way, I implemented the history of actions in my runtime editor: