AlexMeesters/Component-Save-System

loaded prefab components are not saved again.

Closed this issue · 6 comments

I am saving some spawned prefab components, and switch to a free slot, save the results to the disk.
The prefabs are saved as expected in slot 1
If I then load slot one, add spawn some more components, and save the result to slot 2, the file in slot two will miss all prefab components loaded from slot 1

In what way are you setting the save slot?

When you change the slot through the SaveMaster, you should use "notifyListeners = true".
This will notify the saveables to use the new savegame. This will apply a "Load" to those objects tough. I'll add functionality to ensure the reference is always set for all Saveables upon slot change, even with notifyListeners turned off. Does this sound like the solution for your problem?

I'm using
SaveMaster.SetSlotToNewSlot(true, out i); SaveMaster.SyncSave(); SaveMaster.WriteActiveSlotToDisk();

To load I use SetSlot() and SyncLoad()
If I understand it right it is not the notifyListeners flag then.
It seems to only apply to spawned prefabs, other Saveables get saved again to the new slot.

Something I noticed which I am not sure if it is related to this issue, Prefabs require a slot to be set before they can be spawned, while regular objects work just fine, with a slot only being set just before actually saving.

My apologies for the late response.

I've found the culprit and I will be posting a fix today.
Apparently it has to do with the OnSaveCondition().
Objects that use this will never pass this check if you try to resave, since no data has been changed on the components locally.

To solve this issue, I will ensure the OnSaveCondition() gets bypassed the first time a Saveable attempts to save to a new savegame.

Found more issues regarding multiple scenes & saveable prefabs.
I'll be combining it into a bigger update that will release this weekend.
I will also add a method that allows you to duplicate a save game & load that on a different slot.

I've just uploaded a new release to the releases panel.
The fix related to this issue has also been uploaded.