I need help to get some structure for my save and load.

I am making a city builder, so I have Buildings thats need to be saved.

Each building has a lot of static Data, for example name, description, etc.

However it also has a lot of dynamic Data, for example worldPosition, id, etc.

My current structure looks like this:

On each Building GameObject I keep a reference to a ScriptableObject that stores all the static data. I also store a reference to an Object that stores all the dynamic data.

This means I need 2 classes for storing Building data, which I already don't like (BuildingStaticData & BuildingDynamicData)

When I Save/Load my game I only need to store the Dynamic data, so for saving I just save the DynamicData.

For Loading I load the DynamicData, and instantiate a Building GameObject that is associated with it, then the GameObject has the reference to the StaticData.

While this works, I would prefer to have a structure where I only have a single class for BuildingData, but I also don't want to lose the power of a ScriptableObject where I can reference other Prefabs etc.

I need some help with this logic.

  • \$\begingroup\$ Isn't your "static data" just "building type" for your "dynamic data"? Can you put a "building type" variable for your dynamic data object. It should be a bit of a work but you would be getting rid of your "static data" object. \$\endgroup\$ – John Hamilton Nov 21 '19 at 10:53
  • \$\begingroup\$ i'm facing a similar architecture issue in my game. What did you end up doing? I too don't want to lose the power of scriptable objects but have a similar mix of static/dynamic data \$\endgroup\$ – shekit Mar 2 at 1:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.