Used saving system from RPG Core in a habit tracking program made in unity

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.

Well done adapting that!

Very cool. I have always found the saving system to be quite flexible but unfortunately due to its discontinuation with c# in the latest .net… it makes me wonder how much we should continue to use it. I feel like for small games, where you don’t care if a player hacks the data, that its fine. Which is mostly what i do… hobbiest making for fun games that I don’t mind people hack. So for me… i will use it until someone teaches me a better way. lol.

I would never use it for a commercial product because of the security risks of using the binaryformatter.

Eventually I’m going to go through the tutorials to convert it to Json provided by @Brian_Trotter

Make sure you follow my final version of this: Json 1 Introduction and Installation · Wiki · Brian K. Trotter / RPGMods · GitLab
Note that if you are using 2021.3 or later, you likely already have Newtonsoft’s Json installed. You can check in the Package manager.

1 Like

Privacy & Terms