I am looking for a way to receive information about an undo/redo that has happened, specifically in the level-editor viewport for actors being moved/deleted.
For context, I am building a 3D navigation mesh, and require to update this navigation mesh after any mesh its transform state has changed.
There are multiple delegates like ‘OnActorsMoved’, ‘OnActorsDropped’, ‘OnActorsPasted’, ‘OnActorsDuplicated’, and ‘OnActorsDeleted’. These methods work fine and I can tell what actor(s) have been updated. But the problem is that these events are not being called whenever you trigger an undo/redo, which for example resets the transform to a previous location, or undeletes an actor.
The only accessible event that is related to undo/redo is the ‘FEditorDelegates::PostUndoRedo’, but this event does not pass any arguments.
This means that we cannot tell which of the two has happened (undo or redo), and we also cannot tell what specific actor(s) have changed after this operation.
I’m really curious if there is some kind of way to access the info about an undo/redo that has taken place in the level-editor viewport, and specifically use it to get information about what actor has been affected by this.
Ended up building my own simple snapshot system keeping track of the changes in actor transforms. It works perfectly, but it would’ve been easier to setup had there been a few basic delegates for this.
The level-editor viewport already responds to these undo/redo operations by changing the actor in question to its previous state. So why wouldn’t the developers of this engine take the extra step to add this convenience to us? You would think simple events like these should exist in a program meant for moving/editing objects all the time. But instead the only delegate related to this is ‘PostUndoRedo’ that does not give any details about what happened whatsoever.
I noticed that this post is on the first page on google when you search for ‘PostUndoRedo’, so here is a solution that will allow you to listen to an undo or redo specifically.
While this does not give any information about the operation itself and what has changed, it does make it much easier to create your own system that needs to react to one of these specifically.
Solution:
Step 1: derive your class from ‘FEditorUndoClient’.
class UClassName : public FEditorUndoClient
Step 2: override the ‘PostUndo’ and ‘PostRedo’ that are defined on ‘FEditorUndoClient’.