Page 1 of 3

Continue last save/preview saves

Posted: Fri Oct 07, 2022 11:50 am
by tabtaste
Hey all.

1. How can i create a button that appears only wen a save exist. if more then 1 save exist i will load the last save. like a continue butto.

2. how can i preview my saves. a want to create a list with a max of 4 saves and show a picture, savedate and complete status from this save. how can i get infos from a save from slot without loading the save from slot.

greetings!!!

Re: Continue last save/preview saves

Posted: Fri Oct 07, 2022 1:12 pm
by Tony Li
Hi,
tabtaste wrote: Fri Oct 07, 2022 11:50 am1. How can i create a button that appears only wen a save exist. if more then 1 save exist i will load the last save. like a continue button.
When you save a game, also set a PlayerPrefs key to the slot # of the save. Example:

Code: Select all

SaveSystem.SaveToSlot(slotNumber);
PlayerPrefs.SetInt("Last Slot", slotNumber);
You can add a script with a Start() or OnEnable() method to the button that checks the PlayerPrefs value:

Code: Select all

bool hasLastSave = PlayerPrefs.HasKey("Last Slot") && SaveSystem.HasSavedGameInSlot(PlayerPrefs.GetInt("Last Slot"));
gameObject.SetActive(hasLastSave);
tabtaste wrote: Fri Oct 07, 2022 11:50 am2. how can i preview my saves. a want to create a list with a max of 4 saves and show a picture, savedate and complete status from this save. how can i get infos from a save from slot without loading the save from slot.
Please see: How To: Include Summary Info In Saved Games

Re: Continue last save/preview saves

Posted: Fri Oct 07, 2022 1:47 pm
by tabtaste
thanks for the great reply!

one more question. can i change the destroy saver status from a or all objects?

i try to setup a enemy handling like in souls like or hollow knight. enemys still dead between scene but when saving. all enemys except bosses respawn.

greetings

Re: Continue last save/preview saves

Posted: Fri Oct 07, 2022 2:33 pm
by Tony Li
Yes. UNtick the DestructibleSaver's "Save Across Scene Changes" checkbox. It will only save the enemy's destruction status if the player saves and loads in the same scene. If the player moves to another scene and then returns, it will not use the DestructibleSaver's destruction status.

Re: Continue last save/preview saves

Posted: Sat Oct 08, 2022 2:52 am
by tabtaste
Okay thank you but that not what i mean.

What i try to implement is:
Enemy destruction Status should saved between scenes. Also wen i save and load.

I whant reset This Status in a specyfic case. In my case every time wen i save. Wen i save / on a specific trigger all enemys destroction status should be reseted. After This reset wen I loading a scene the emenys in This scene should spawn again

Greetings

Re: Continue last save/preview saves

Posted: Sat Oct 08, 2022 8:52 am
by Tony Li
Hi,

If you want a trigger to reset saver data, you can delete the saver's data. For example:

Code: Select all

public List<Saver> saversToReset; // <- SET IN INSPECTOR

void OnTriggerEnter(Collider other)
{
    if (other.CompareTag("Player"))
    {
        saversToReset.ForEach(saver => SaveSystem.currentSavedGameData.DeleteData(saver.key));
    }
}

Re: Continue last save/preview saves

Posted: Sat Oct 08, 2022 10:01 am
by tabtaste
Okay thanks. In This way i need to assign every Single enemy in the Inspektor right ? Can i Do a easy way to collect All "destructable saver" in the hole game?

Greetings

Re: Continue last save/preview saves

Posted: Sat Oct 08, 2022 11:05 am
by Tony Li
Yes, you could do this:

Code: Select all

void OnTriggerEnter(Collider other)
{
    if (other.CompareTag("Player"))
    {
        foreach (DestructibleSaver saver in FindObjectsOfType<DestructibleSaver>())
        {
            SaveSystem.currentSavedGameData.DeleteData(saver.key));
        }
    }
}
[EDIT: Don't use this. See below for working solution.]

Re: Continue last save/preview saves

Posted: Sat Oct 08, 2022 2:07 pm
by tabtaste
thanks!
great tool, great support!

greetings

Re: Continue last save/preview saves

Posted: Sat Oct 08, 2022 2:15 pm
by Tony Li
Thanks! Happy to help.