CTIN 289 - Interactive Snippets Library

Powered by 🌱Roam Garden

PlayerPrefs


//a way to store variables between play sessions, typically used for settings/preferences

//can store string, float, and integer variables

//in my experience, it works really well for storing the high score on a game

PlayerPrefs.GetVariableType(“keyName”, baseVariable);

//gets a stored variable of the given type with the given name if one exists; if it doesn’t, it returns the given base variable

PlayerPrefs.SetVariableType(“keyName”, newVariable);

//sets the stored variable with the value of the given new variable

PlayerPrefs.HasKey(“keyName”);

//returns whether the given key exists (bool)

PlayerPrefs.DeleteKey(”keyName”);

//removes given key from storage in PlayerPrefs

PlayerPrefs.DeleteAll();

//deletes all stored keys