Hi I’ve been making a habit and reward program for myself in unity and I decided to implement the saving system from the RPG Core course because I don’t know how to create one myself.
I did some minor changes and it works for its intended purpose.
The saving system saves the amount of unlock points spent to unlock rewards that are added to the panel on the right (when they’re clicked they get removed) and saves the amount of rewards unlocked left, which saves automatically when they’re used.
So yes the saving system can be used easily in totally unrelated projects.
The main minor change I had to make was changing the loadscene from an ineumrator to void:
public void LoadLastScene(string saveFile)
{
Dictionary<string, object> state = LoadFile(saveFile);
int buildIndex = SceneManager.GetActiveScene().buildIndex;
if (state.ContainsKey("lastSceneBuildIndex"))
{
buildIndex = (int)state["lastSceneBuildIndex"];
}
RestoreState(state);
}
Because for some reason the original line:
yield return SceneManager.LoadSceneAsync(buildIndex);
Caused an infinite loop of reloading the same scene, I only have one scene for this program so I removed it.