Issues with loading from a saved cache file
Posted: Mon Oct 30, 2023 4:44 am
Hello, I've been using Easysave for a while now, but have only recently switched to trying out loading via caching the data.
I've looked over a few resources and posts for an answer, including the performance guide, but I think I've reached my breaking point and decided to ask here on the forums for help since I needed this working as soon as I am able to get it to.
To make the explanation simple:
I have several save slots to load from and create a save file for them via cache like so:
And then in a separate function I later load the save data based on saveName
This is a simplified version of the code, but I think it illustrates the idea as best as possible. Because I have scripts outside of the save/load script that access the save/load functions, and because these functions are separated, I opted to make to the ES3Setting into a public variable so it can be easily used. It is set at the beginning of each session during the game startup!
Typically, this works totally fine and the data is loaded and applied without issue. However, if I stop runtime and then attempt to load from the stored cache file after starting a new runtime session, said custom class will no longer be loaded properly and will result in a null/empty reference in my scene. I feel like I am misunderstanding how to properly utilize the stored cache file as I am using it for the faster save/load times.
Since it works if I save and then load within the same session, I imagine I might be screwing up somewhere without realizing it!
Any help would be appreciated, as this was a last minute bug I realized pretty late! Thank you very much for any response!
I've looked over a few resources and posts for an answer, including the performance guide, but I think I've reached my breaking point and decided to ask here on the forums for help since I needed this working as soon as I am able to get it to.
To make the explanation simple:
I have several save slots to load from and create a save file for them via cache like so:
Code: Select all
public ES3Settings saves;
OnGameStartup(){
saves = new ES3Settings(ES3.Location.Cache);
}
Save(){
saveName = name + number;
ES3.Save<List<CustomClass>>("sceneIndex", CustomClassReference, saveName, saves);
ES3.StoreCachedFile(saveName, saves);
}
Code: Select all
Load(){
saveName = name + number;
ES3.CacheFile(saveName, saves);
ES3.LoadInto<List<CustomClass>>("sceneIndex", saveName, CustomClassReference, saves);
}
Typically, this works totally fine and the data is loaded and applied without issue. However, if I stop runtime and then attempt to load from the stored cache file after starting a new runtime session, said custom class will no longer be loaded properly and will result in a null/empty reference in my scene. I feel like I am misunderstanding how to properly utilize the stored cache file as I am using it for the faster save/load times.
Since it works if I save and then load within the same session, I imagine I might be screwing up somewhere without realizing it!
Any help would be appreciated, as this was a last minute bug I realized pretty late! Thank you very much for any response!