How to check if save file exists

Hi how do we check if the save file exists? I’d rather check that and use a bool from saving system or wrapper and set the health based on that.

I’m having issues with the current solution and I also think it will lead to potential issues down the road with forgetting why we’re checking if the enemies health is < 0 first.

In SavingSystem, you need a method to see if a given save file exists:

    public bool FileExists(string saveFile)
    {
        string path = GetPathFromSaveFile(saveFile);
        return File.Exists(path);
    }

and in SavingWrapper, you need a method that uses the actual save file name:

    public bool SaveFileExists()
    {
        return GetComponent<SavingSystem>().FileExists(defaultName);
    }

All that being said, there is a structural defect in your plan… If you transition from scene 0 to scene 1, then SaveFileExists() will return true, but the enemies in the scene won’t have had their health within that save file, and as such will not have their health properly set.

Privacy & Terms