![]() |
VOOZH | about |
PlayerPrefs saves data as key-value pairs. You give each piece of data a unique key name and a value. Unity stores this data in a file on the player's device.
PlayerPrefs supports only these three data types:
100, 9999 - Used for score, level number, coin count.0.75, 1.5 - Used for volume and settings."Player1", "Easy" - Used for player name and difficulty.Use these methods to save data:
SetInt(), SetFloat(), SetString() store the value in memory. Save() writes it to disk. Without Save(), data may be lost if game crashes.
Use these methods to load previously saved data:
The second parameter is the default value if the key doesn't exist. Always provide a default value.
Sometimes you need to check if data was saved before
HasKey() returns true if the key exists in PlayerPrefs.
Delete specific keys or all data:
DeleteKey() removes one key. DeleteAll() clears everything - useful for a "Reset Game" button.