Call functions during ShutdownModule() for a plugin

Hi, I wounder what the possibilities are to call functions that will i.e. delete certain type of actors and a folder in the World Outliner on the event of unloading a plugin in the plugins manager. And in other words calling functions in the “ShutdownModule()” for the plugin.
I tried to call two functions to delete actors and folder but didn’t work. The functions themselves work but from another calling event in PIE. I guess the subsystem that deals with this has already been unloaded during the Shutdown phase? The reason I want to delete a certain type of actor(s) is because they are associated with the plugins window, and when the engine has restarted after the plugin unload I want to make sure no associated actor(s) are left . Any ideas on how to make this work?
Thanks!

Hi, are you wanting those actors to stay there between restarts of the editor if the plugin is still enabled, or a generic system that removes those actors whenever the level is unloaded (the plugin recreates each time the level is edited)?

Hi,
For your first question, yes and the actors associated with the plugin indeed remains in the world between restarts of the editor if the plugin is still enabled.
I belive I am looking for a generic system that removes those actors when ever the level is unloaded, or more likely when ever the plugin is unloaded/ disabled controlled by the plugins window. I have started with the toolbar button plugin template which contains the ShutdownModule function and my first thought was to add the “DeleteActors” function within the ShutdownModule. But it feels like it will never have time to finish executing before editor restarts and the plugin has been successfully unloaded.

The ShutDownModule gets called when UE is exited, even if the plugin is still enabled it will still remove those actors.

I can’t think of any way to conditionally remove the actors on the plugin being disabled (maybe someone wiser than me knows a way).

A way to stop the actors from loading in the level if the plugin has been disabled could be to create your own Actor class subclassed from AActor and add those instead of normal AActors - if the plugin isn’t enabled when the level is loaded it will remove them (but there will be error messages in the log).

Ok thanks for giving suggestions and idea
s. :+1:

1 Like