PlayerPrefs is a class in Unity that is used for storing and accessing player preferences between game sessions. Here's where
PlayerPrefs data is typically stored on different platforms:
[ProductName] are the company and product names you've set in your project settings.
~/Library/Preferences/folder, the folder being named as the reverse DNS style bundle identifier (
Android: PlayerPrefs uses
SharedPreferences. The data is saved in an XML file in the app's private folder, located at
pkg-name is your application's package name.
iOS: PlayerPrefs data is stored in
NSUserDefaults and is backed by a
.plist file within the app's sandbox.
WebGL: PlayerPrefs data is stored in the browser's IndexedDB.
Please note that while accessing or modifying PlayerPrefs is straightforward through the
PlayerPrefs class methods like
HasKey, etc., directly manipulating the storage files (registry entries for Windows, plist files for macOS, etc.) is not recommended as it could lead to data corruption or unexpected behavior in your game.
It is also important to understand that PlayerPrefs is meant for lightweight data storage and is not secure. Users with access to these paths can easily read or write to the PlayerPrefs data. Therefore, sensitive information should never be stored in PlayerPrefs.
Here's an example of using PlayerPrefs to store and retrieve a high score in Unity: