Bypass saving certain actors in editor?

Would there be a way to bypass saving certain objects on an editor level without changing engine code? For example, all actors of class ATemporaryActor would never be saved to the level no matter how many times someone placed it in the world and pressed ctrl+s. The idea is to be able to place these actors, save the map, close the editor, and next time the editor is opened, it’s as if these actors never existed.

The alternative could be to delete every one of these actors right before any attempted save from any source (ctrl+s, drop downs in file, auto save), I’m guessing all of these sources eventually call the same ‘save level’ function, but I’m not sure how to call my function that deletes all my actors right before this 's ‘save level’ process.

I don’t know much about engine architecture in general, let alone UE4’s, so any help or tips to at least get me started would be appreciated!

Edit: setting bEditable to false seems to do the work, unfortunately this means I can’t edit the actor which I intend on doing. Might be possible to play around with this variable but it seems like a hack

What you could do is place a “On Level Loaded” event in your Level Blueprint, and in that event, find all actors of your class and destroy them.

Alternatively, you might be able to set the UCLASS as Transient in C++ but I am not sure if that would work.

As DamirH suggested, actually the best way to achieve this is to make sure any instances have the RF_Transient flag. This ensures they will never get saved.

You can add this as a class flag if you wish:

UCLASS(Transient)
class ATemporaryActor ...
1 Like

Thank you