player pref first time set up

hi im trying to set the player pref for first time a player uses the game.
so i want to do

if(PlayerPrefs.GetInt("example") == null)
{
PlayerPrefs.SetInt("example",1)
}

is null the default setting on playerprefs?
thanks

PlayerPrefs.HasKey(“example”)

it will return true if it is assigned already otherwise it will return false…

so You Can Write

if(!PlayerPrefs.HasKey(“example”))
PlayerPrefs.SetInt(“example”,1);

Just use

PlayerPrefs.GetInt(“example”, 1);

1 Like