unity how to use playerprefs code example
Example 1: how to use playerprefs in unity
SAVING
PlayerPrefs.SetInt("score",5);
PlayerPrefs.SetFloat("volume",0.6f);
PlayerPrefs.SetString("username","John Doe");
PlayerPrefs.Save();
bool val = true;
PlayerPrefs.SetInt("PropName", val ? 1 : 0);
PlayerPrefs.Save();
READING
int score = PlayerPrefs.GetInt("score");
float volume = PlayerPrefs.GetFloat("volume");
string player = PlayerPrefs.GetString("username");
bool val = PlayerPrefs.GetInt("PropName") == 1 ? true : false;
Example 2: playerprefs unity
int number = 18;
float decimal = 1.84f;
string word = "Jeff";
PlayerPrefs.SetInt("Age", number);
PlayerPrefs.SetFloat("Height", decimal);
PlayerPrefs.SetString("Name", word);
Debug.Log(PlayerPrefs.GetInt("Age"));
Debug.Log(PlayerPrefs.GetFloat("Height", 1.5));
Debug.Log(PlayerPrefs.GetString("Name"));
PlayerPrefs.DeleteKey("Height");
P layerPrefs.DeleteAll();