How to do conditional serialization properly?

Hey everyone,

TL;DR: I want an object that:

  • Always saves itself to an uncooked package
  • Saves itself to a cooked package under certain conditions only

Details:

I have created a “manager” class for my data and this manager object exists within the UWorld class. Inside the manager object I have a set of smaller “state” objects and a few settings that can be set from the editor. I want the manager object to only be saved when it has at least one state object OR when we are NOT cooking. The logic is that the level designer may have edited some settings on the manager object so we should always save it when saving in editor. But the manager object is useless on runtime when it has no state objects so I would like to check it when cooking so I can save some memory on cooked builds.

Thanks!

Robert.