I dont understand how or what is going on to make the game save your settings

I’m on the save and exit part of the course.
Could someone explain what exactly is going on behind how it saves what you want?
On the Save and Exit method challenge, I was completely stumped.

Hi Josh,

Have you already watched the video at least one more time without following along in Unity?

The PlayerPrefs are like a dictionary with a key, which is, for example, “MASTER_VOLUME” and a value, which is, for example, 0.8f. You can read that value from the PlayerPrefs by calling PlayerPrefs.GetInt("MASTER_VOLUME");, or you can set it by calling PlayerPrefs.SetInt("MASTER_VOLUME", 1f);.

We use a PlayerPrefsManager class/instance because we do not want to access the PlayerPrefs all over the place in our project. For this reason, we have all our methods call our own instance. This allows us to replace the PlayerPrefs if necessary. If your game becomes more complex, you might want different way to store your data, for example, in a database. Instead of changing something in multiple scripts, you can focus on the PlayerPrefsManager.

Does that make sense?

1 Like

Ah yes I think that explains it.

So Playerprefs is something we have to write ourselves. There is no preference saving solution built in to the engine.

The PlayerPrefs are a simple saving solution provided by Unity.


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms