playerpref bool unity code example

Example 1: player prefs convert int to bool

PlayerPrefs.GetInt("YourPrefName") == 1 //Returns true false depending on value

Example 2: playerprefs and bools

public static void SetBool(string name, bool booleanValue) 
	{
		PlayerPrefs.SetInt(name, booleanValue ? 1 : 0);
	}
 
	public static bool GetBool(string name)  
	{
	    return PlayerPrefs.GetInt(name) == 1 ? true : false;
	}
 
	public static bool GetBool(string name, bool defaultValue)
	{
	    if(PlayerPrefs.HasKey(name)) 
		{
	        return GetBool(name);
	    }
 
	    return defaultValue;
	}