Answers for "how to use playerprefs in unity"

C#
12

how to use playerprefs in unity

SAVING
 
 PlayerPrefs.SetInt("score",5);
 PlayerPrefs.SetFloat("volume",0.6f);
 PlayerPrefs.SetString("username","John Doe");
 PlayerPrefs.Save();
 
// If you need boolean value:

 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;
Posted by: Guest on October-11-2020
4

playerprefs unity

//Variables of different type
	int number = 18;
	float decimal = 1.84f;
	string word = "Jeff";

//Setting each PlayerPref to a Variable, with .Set and the type of Variable its set too (.SetFloat)
	PlayerPrefs.SetInt("Age", number);
	PlayerPrefs.SetFloat("Height", decimal);
	PlayerPrefs.SetString("Name", word);

//Displaying the PlayerPref in Console, with .Get and its type of data (.GetString)
	Debug.Log(PlayerPrefs.GetInt("Age"));
	Debug.Log(PlayerPrefs.GetFloat("Height", 1.5));// Adding a default Value incase the PlayerPref isn't storing any data
	Debug.Log(PlayerPrefs.GetString("Name"));
/*Desplayed in Console:
	18
	1.84
	Jeff
*/

//Reseting data in one PlayerPref
	PlayerPrefs.DeleteKey("Height");
//Reseting data in all PlayerPrefs
P	layerPrefs.DeleteAll();
Posted by: Guest on October-25-2020
0

playerprefs stored at unity

windows+R >> regedit >> HKEY_CURRENT_USER\SOFTWARE\Unity\UnityEditor\CompanyName\ProjectName
Posted by: Guest on December-27-2020
0

unity playerprefs

//Variables of different type
	int number = 18;
	float decimal = 1.84f;
	string word = "Jeff";

//Setting each PlayerPref to a Variable, with .Set and the type of Variable its set too (.SetFloat)
	PlayerPrefs.SetInt("Age", number);
	PlayerPrefs.SetFloat("Height", decimal);
	PlayerPrefs.SetString("Name", word);

//Displaying the PlayerPref in Console, with .Get and its type of data (.GetString)
	Debug.Log(PlayerPrefs.GetInt("Age"));
	Debug.Log(PlayerPrefs.GetFloat("Height", 1.5));// Adding a default Value incase the PlayerPref isn't storing any data
	Debug.Log(PlayerPrefs.GetString("Name"));
/*Desplayed in Console:
	18
	1.84
	Jeff
*/

//Reseting data in one PlayerPref
	PlayerPrefs.DeleteKey("Height");
//Reseting data in all PlayerPrefs
P	layerPrefs.DeleteAll();
Posted by: Guest on April-21-2021

Code answers related to "how to use playerprefs in unity"

C# Answers by Framework

Browse Popular Code Answers by Language