Save System - Different slots loading same data

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
EpicMcDude
Posts: 24
Joined: Fri Sep 22, 2023 5:05 pm

Save System - Different slots loading same data

Post by EpicMcDude »

Hi,

I'm not sure if it's me doing something wrong but the save system seems to get data from a different slot when loading.

I experimented with an object that has a destructible saver -
I saved the game on Slot 1 with the object intact, then I destroyed it and saved the data to Slot 2 (I use "Load Game From Slot" and "Save Game To Slot").
Then I load Slot 1 and the object loaded correctly, it's intact.
Then I load Slot 2 and the object loaded correctly, it's destroyed.
But then I load Slot 1 again after loading Slot 2 and it's now destroyed and deactivated from the Scene (the Destroy Mode is set to Deactivate and the Mode is On Destroy).

Only seems to happen when loading different slots consecutively

If you need any more information let me know!
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save System - Different slots loading same data

Post by Tony Li »

Hi,

Is your Save System component's "Save Current Scene" checkbox ticked? When it's ticked, the save system reloads the scene that the game was saved in. This allows the save system to apply saved data to a fresh instance of the scene.

If that info doesn't help, are there any errors or warnings in the Console window?
EpicMcDude
Posts: 24
Joined: Fri Sep 22, 2023 5:05 pm

Re: Save System - Different slots loading same data

Post by EpicMcDude »

Tony Li wrote: Sat Aug 03, 2024 12:03 am Hi,

Is your Save System component's "Save Current Scene" checkbox ticked? When it's ticked, the save system reloads the scene that the game was saved in. This allows the save system to apply saved data to a fresh instance of the scene.

If that info doesn't help, are there any errors or warnings in the Console window?
Hi Tony,

Since you mentioned that, I've been testing the Saver components with it ticked off and applying the saved data myself and it's working well!
Except for one issue, where when I destroy an object, save, and instantiate a prefab variant with the Spawned Saver component save and then load again, it'll still activate the original object as if the Destructible Saver component didn't work.

Checking the Save file and searching for the key given to the Destructible Saver component it's now gone from the save file, like it removed itself, so it makes sense the object would be active since that was the original state in the scene. not sure what to do!
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save System - Different slots loading same data

Post by Tony Li »

Hi,

If you're using a Spawned Object Manager component, is its "Apply Save Data To Spawned Objects On Restore" checkbox ticked?
EpicMcDude
Posts: 24
Joined: Fri Sep 22, 2023 5:05 pm

Re: Save System - Different slots loading same data

Post by EpicMcDude »

Tony Li wrote: Sat Aug 03, 2024 8:06 pm Hi,

If you're using a Spawned Object Manager component, is its "Apply Save Data To Spawned Objects On Restore" checkbox ticked?
It's ticked off, same behaviour happens when I tried with it ticked on
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save System - Different slots loading same data

Post by Tony Li »

Does the destroyed object and the instantiated object have the same saver Key? If so, maybe they're stepping on each other's data using the same key.

If you're using a Spawned Object Manager component, it will automatically assign a unique key to each instantiated object.
EpicMcDude
Posts: 24
Joined: Fri Sep 22, 2023 5:05 pm

Re: Save System - Different slots loading same data

Post by EpicMcDude »

Tony Li wrote: Sun Aug 04, 2024 10:40 am Does the destroyed object and the instantiated object have the same saver Key? If so, maybe they're stepping on each other's data using the same key.

If you're using a Spawned Object Manager component, it will automatically assign a unique key to each instantiated object.
Yeah, what I'm doing is each prefab has their saver component Key fields empty, so that when I put them in the scene I can use the menu option in the toolbar "Tools/Pixel Crushers/Common/Save System/Assign Unique Keys" and have unique keys for each prefab already in the scene.

The prefabs that get instantiated are Prefab Variants of those prefabs, with all their saver components removed but with the Spawned Object Saver component added with "Save Unique Saver Data" ticked. So all the keys are different

I've been testing it and I don't know why it happens but when I delete or destroy both objects, one of them deletes itself from the save file and doesn't get loaded properly.
Last edited by EpicMcDude on Sun Aug 04, 2024 10:02 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save System - Different slots loading same data

Post by Tony Li »

Your scene should have only one Spawned Object Manager. Is that the case?

If so, temporarily tick the Save System component's Debug checkbox and the PlayerPrefs Saved Game Data Storer component's Debug checkbox. (Temporarily change to PlayerPrefs Saved Game Data Storer if you're using another such as Disk Saved Game Data Storer.)

Then reproduce the issue in the Unity editor's play mode. When you save and load, it will log the save data to the Console window in JSON text format. You can search the output for your saver keys to get an idea of what's getting saved.

And if that doesn't help, feel free to send a reproduction project to tony (at) pixelcrushers.com. I could take a look and let you know what I find.
Post Reply