Forum rules - please read before posting.

Where does the save game file get saved to

Hi, where can I go to delete the save game file that gets created from the settings menu? Because in my game it is checking to see if there is a profile first and if there isn't one I can create one and then if there is one it does something different. Just like in the hidden object games. But I need to be able to delete and start from scratch or do I have to build the game first. I'm only asking is because I don't people to have my saved game.

Comments

  • Save game files and Options data are separate. The Settings Manager handles your Options data, which is stored in PlayerPrefs.

    These are separate to save files that you access via the Save/Load menus. Their exact location will be unique to each computer, but displayed in the Console when accessed in the Editor. If you load a file while playing in the Unity Editor, open the Console window to find the location it's retrieved from.

  • But my console only says what is loaded and not where its loaded from. So it only says the name of the file that is loaded and doesn't say the directory though. But maybe I haven't done it properly when I am just using profiles but ingame when I enter my name it goes in the profiles and when I exit and then try it again it still has that same name so it is getting saved. So I assuming creating profiles saves as well do they or do I still have to do the save/load action. I am going to have it where it is autosaving and save is under your profiles just like the hidden object games from www.bigfish.com

  • What does the Console say exactly, and what platform are you building to?

    If you're building to WebGL, then save files are stored in PlayerPrefs - since WebGL doesn't allow for saving to the filesystem due to security.

    Profiles are part of the Options data, and so always saved to PlayerPrefs regardless of the platform. Save game files are unique to a profile.

    Your PlayerPrefs are unique to your system - users on other machines won't have access to them.

  • Just your first normal build and now I understand. Thank you for your help.

  • edited June 2021

    If you're building to WebGL, then save files are stored in PlayerPrefs - since WebGL doesn't allow for saving to the filesystem due to security.

    I'm having problem with save games not being persisted in WebGL.
    1. Do I understand correctly that no .save files get's generated under Application.persistentDataPath when running in WebGL?
    2. When I look for saved games I loop through all save slots and check SaveSystem.DoesSaveExist(i) - would this check behave reliable when running in WebGL?
    3. What would be the easiest way to override the folderpath to use when reading/writing savegames to when running in WebGL?

    Thanks

  • Do I understand correctly that no .save files get's generated under Application.persistentDataPath when running in WebGL?

    They should be saved in PlayerPrefs, bypassing the use of .save files.

    Though, it may be that this has stopped being the case - since I'm seeing the top of the SaveSystem script only checking for UNITY_WEBPLAYER as opposed to UNITY_WEBGL to define the SAVE_IN_PLAYERPREFS symbol. I'll look to see if this should be updated, but give this a try yourself and see if that resolves your save issues.

    When I look for saved games I loop through all save slots and check SaveSystem.DoesSaveExist(i) - would this check behave reliable when running in WebGL?

    It should work regardless of your save file handler.

    What would be the easiest way to override the folderpath to use when reading/writing savegames to when running in WebGL?

    WebGL shouldn't rely on files or folder paths, it should save in PlayerPrefs. You can, however, manually switch file handler through script - see the "Custom save formats and handling" chapter of the Manual.

  • edited June 2021

    I see. I implemented my own subclass to specify a new path (without the #if !SAVE_IN_PLAYERPREFS line) which seems to be working fine (I made the SaveFileHandler_SystemFile.GetSaveDirectory virtual). Not sure if it now also saves in playerprefs though...

    Do you remember the reason to save games in playerprefs for WebGL? If it was an older limitation it might be worth scrapping since there seem to be a max size involved in the playerprefs file on WebGL.

    Thanks

  • Aside from the security concern I mentioned above, files saved via WebGL are only available for that session - reloading a browser when using SaveFileHandler_SystemFile will cause saves to be lost.

  • I'm using a WebGL "host" that allows for save files to be cloud synced which seems to be working now. So it would be great if it wasn't hard coded whether a specific platform defines the SAVE_IN_PLAYERPREFS or not. Maybe that too could be defined in the inherited classes.

    I'll try manually updating the checks for UNITY_WEBPLAYER to UNITY_WEBGL without using my custom classes just to see if that works too.

  • edited July 2021

    Ok, I tried updating the symbols to have AC save in PlayerPrefs . This worked, but the playerprefs sizelimit was hit rather quickly, giving this warning (and skipping to save):

    Could not save PlayerPrefs data under key SaveVersion1_4. Exception: UnityEngine.PlayerPrefsException: Could not store preference value

    So I really need a way to be able to keep the derived class solution (which worked great), and still keeping AC from defining SAVE_IN_PLAYERPREFS while in WebGL. Others might need this too for various console platforms in the future so perhaps a simple solution would be to add a DISABLE_SAVE_IN_PLAYERPREFS that explicitly prevents it?

  • The SAVE_IN_PLAYERPREFS define only deals with setting the default save method - it can be overridden through setting the SaveFileHandler property:

    SaveSystem.SaveFileHandler = mySaveFileHandler;
    
  • I see, so that should be enough.

    The only trouble now is this: I expect you will add UNITY_WEBGL to the checks in SaveSystem which is fine coz its effect will be overridden. But there is a similar check in SaveFileHandler_SystemFile that is used to remove the whole class when SAVE_IN_PLAYERPREFS isn't defined. Would you consider removing that check since it makes makes deriving from SaveFileHandler_SystemFile impossible when SAVE_IN_PLAYERPREFS is set to true?

  • I will consider it, yes.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.