Saving / loading data organization

If I’m using a 3rd party data saving asset, is it better to have a controller game object that must be referenced to load / save a particular point of data or to just call the save / load method in whatever script I’m working in?

// IN A SAVING / LOADING CONTROLLER GAMEOBJECT
public int LoadChoiceCount () {
        int defaultValue = 0;
        int count = ES3.Load<int>("choicesCount", defaultValue);

        return count;
}

versus

// IN A RANDOM SCRIPT
private void RandomMethod () {
   int defaultValue = 0;
   int count = ES3.Load<int>("choicesCount", defaultValue);
}

Personally, I prefer to save everything in one go via a save class. Although, at a guess, that asset is saving using player prefs which is something I think nobody should every use :smile:

1 Like

What about one variable that changes, then needs to be read in another scene?

I tend to use scriptable objects for data which needs to be shared between classes.

Saving to disk just to move data between scenes is not a very good approach. An object with DontDestroyOnLoad or static variables are better.

I’m currently working on a blackboard system, where I keep crucial data like this in memory. Obviously it is a static, global key-value pair storage where I can save things. The way it works is: if something needs to be saved I assign a unique ID to it. It does not change even if I restart the application.
Then I store various features I think needed to save a game in this blackboard at various events (like kill a character, drop an item, change scene, etc). When the save happens I will save this blackboard into the file.
When I need to reload the game I load the saved file and anything I find there apply after the defaults come online. This way the edited values will take precedence unless the game saved any newer data.
It also can be read when you go back to the previous scene, so you can overwrite the defaults just like when you load game.
This is a system I could think of, although it is not working yet, I just started to implement some aspects of it.