Game Development Reference
In-Depth Information
Tip
It's not recommend that you call
PlayerPrefs.Save()
during the actual gameplay,
because it will write the data to the disk and cause small hiccups. More details can be
We use
PlayerPrefs.GetString(Key,DefaultValue="")
,
Player-
Prefs.GetFloat(Key,DefaultValue=0.0f)
, and
Player-
Prefs.GetInt(Key,DefaultValue=0)
to load the data. These methods will get
the data value from the given key string. If the key cannot be found, it will return the de-
fault value depending on the individual function. We can also use
Player-
Prefs.HasKey(Key)
to check if the key exists or not. At last, if we want to remove
the key data, we can use
PlayerPrefs.Delete(Key)
to remove the specific key.
Also, if we want to remove all the keys, we can use
PlayerPrefs.DeleteAll()
.
Note