Library:Unity/PlayerPrefs
Where Unity's PlayerPrefs save data lives on each platform: registry key on Windows, plist on macOS, XML on Android, files on Linux, NSUserDefaults on iOS, IndexedDB on WebGL.
Locations
From the Unity scripting reference for PlayerPrefs (company and product names come from Player Settings):
- Windows: registry
HKEY_CURRENT_USER\Software\<CompanyName>\<ProductName>. - Windows UWP:
%userprofile%\AppData\Local\Packages\<ProductPackageId>\LocalState\playerprefs.dat. - macOS:
~/Library/Preferences/<BundleIdentifier>.plist; the default identifier iscom.<CompanyName>.<ProductName>. - Linux:
~/.config/unity3d/<CompanyName>/<ProductName>. - Android:
/data/data/<package>/shared_prefs/<package>.v2.playerprefs.xml(Android SharedPreferences XML). - iOS: NSUserDefaults (inside the app's Library/Preferences plist).
- WebGL: the browser's IndexedDB, limited to about 1 MB.
Windows registry value names
Each pref is one registry value. The name is the key you passed, followed by _h and a decimal number: a hash of the key (community reports describe a djb2-style hash with seed 5381 and XOR; Unverified, check against a game before relying on it). Example names: Coins_h2345678901. So to read a pref outside the game you must strip the _h<number> suffix; to write one you must compute the same hash.
Value types (community reports, Unverified): ints and floats are DWORD (a float's bits stored as a DWORD, so Regedit shows it as an invalid DWORD); strings are REG_BINARY with the UTF-8 bytes and a trailing NUL. Check by saving one value of each type in a test project.
Pitfalls
- Plain PlayerPrefs are not encrypted; games that care wrap them in their own obfuscation, so a base64-looking string may need the game's key.
- In the Editor, prefs are stored under a different key (
Software\Unity\UnityEditor\<Company>\<Product>on Windows, Unverified).
Related
Library:Unity, Library:Unity/Game folder layout.
Save files that games write themselves with .NET BinaryFormatter are described in Format:NRBF (.NET BinaryFormatter stream); method overview in Technique:Reverse engineering game save files.