Adding On(Pre/Post)SaveWorld Handles in Editor

It seems like you need to create a class extending UUnrealEdEngine as well as create a new module.
Here’s a post detailing what you need to do.

Hopefully this helps!

So I’ve been making use of the amazing slate system along with Unreal’s plugin functionality (great job on that, Epic) to create a plugin that allows for the “dumping” of a 2D grid (like in a Civilization game) on top of 3D world geometry. Part of the plugin involves an editor mode that allows for interaction and manipulation of the grid (again, this is an IN-EDITOR, NOT RUNTIME module). Everything was going well until I ran into a problem (possibly an engine bug) relating to config variables as the world is being saved (via CTL+S).

I have a small global ConfigManager that is responsible for maintaining a few properties that is used to draw the actual grid on the screen. My issue is that whenever I tried to save a level while also drawing the grid and reading from these variables (which it must do to draw each frame), I would crash due to trying to reference some crazy overflow value from an array resulting from a corrupted config variable. I’ve done a lot of debugging and confirmed that during the save event the config variables become temporarily corrupted, but are returned to their proper values upon save completion.

In an attempt to cleanly fix this issue I’d like to add handles to UEditorEngine::OnPreSaveWorld and UEditorEngine::OnPostSaveWorld to make sure that I don’t try to render during a save. Unfortunately I’m at a loss of how to do that. Do I need to derive an entirely new UEditorEngine for the editor to use? That seems unnecessarily bulky, but I’ve been unable to find any help online other than the minimalist official doc pages.

Any advice on adding those handles or otherwise fixing this issue? I’d like to avoid keeping local structures to keep track on the config data and updating it as needed if possible. Thank you so much!

Thanks for the response, but that seems to be primarily about just setting up an editor plugin. I’ve already done all of that. As for extending a new UUnrealEdEngine, I’d still be at my previous point of not wanting to make an entirely new editor class just to get a callback for when the level is being saved. This is because I suspect this would conflict with other plugins that also create a new editor (I’m really not sure about this, though) and again that solution seems extremely bulky for the small problem trying to be fixed.

Then again, if that really is the only way to solve this problem, would anyone at least be able to confirm that plugins that extend different editors do or do not conflict?