Forum rules - please read before posting.

Loading custom savegame files

edited July 2019 in Technical Q&A

Hi,

Is it natively possible to load a custom SaveGame from a user specified location?

Didn't find any viable public functions in SaveSystem and had to hack private void Load (SaveFile saveFile, bool doLog) to public, which does works like a charm!
If there is no such function would it be possible to add one? Loading custom savegame files is great for testing IMO.
Thanks!

AC 1.68.1

Comments

  • You can implement a new iSaveFileHandler class, which is used to determine where save files are stored. The default class, SaveFileHandler_SystemFile, stores such files in Unity's Application.persistentDataPath, which is standard practice.

    See the Manual's "Custom save formats and handling" chapter - you can duplicate this class and assign it as the game's file handler class, and use it to place files wherever you like. You could then wrap this around a scripting define symbol, e.g. #if SAVE_TESTING, so that you enable it only when SAVE_TESTING is listed as a symbol in Unity's Player Settings.

    The next update will also convert the default class's private functions to protected, so that you can more easily create a subclass to override only what you need.

  • Great answer as always, thanks!

    I stored my custom savegames in the StreamingAssets folder, since it's included in build. From there I used Application.streamingAssetsPath to locate the files loaded them. Works on any platform except WebGL and Android.

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.