PlayerPrefs
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Submission failed
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Description
PlayerPrefs is a class that stores Player preferences between game sessions. It can store string, float and integer values into the user’s platform registry.
Unity stores PlayerPrefs in a local registry, without encryption. Do not use PlayerPrefs data to store sensitive data.
Unity stores PlayerPrefs data differently based on which operating system the application runs on. In the file paths given on this page, the ExampleCompanyName and ExampleProductName are the names you set in Unity’s Player Settings.
Standalone player and in-Editor Play mode storage location
— MacOS:
Standalone Player storage location
— Android: /data/data/pkg-name/shared_prefs/pkg-name.v2.playerprefs.xml . Note that C#, Android Java and native code can all access the PlayerPrefs data.
— iOS: Uses the [NSUserDefaults standardUserDefaults] API to store PlayerPrefs data.
— Linux:
— WebGL: Unity stores up to 1MB of PlayerPrefs data using the browser’s IndexedDB API. For more information, see IndexedDB.
— Windows: HKCU\Software\ExampleCompanyName\ExampleProductName
— Windows Universal Platform: %userprofile%\AppData\Local\Packages\[ProductPackageId]\LocalState\playerprefs.dat
In-Editor Play mode storage location
— Windows: HKCU\Software\Unity\UnityEditor\ExampleCompanyName\ExampleProductName key. Note that Windows 10 uses the application’s PlayerPrefs names. For example, Unity adds a DeckBase string and converts it into DeckBase_h3232628825. The application ignores the extension.
PlayerPrefs
Stores and accesses player preferences between game sessions.
Editor/Standalone
On macOS PlayerPrefs are stored in
/Library/Preferences folder, in a file named unity.[company name].[product name].plist, where company and product names are the names set up in Project Settings. The same .plist file is used for both Projects run in the Editor and standalone players.
On Windows, PlayerPrefs are stored in the registry under HKCU\Software\[company name]\[product name] key, where company and product names are the names set up in Project Settings.
On Linux, PlayerPrefs can be found in
/.config/unity3d/[CompanyName]/[ProductName] again using the company and product names specified in the Project Settings.
On Windows Store Apps, Player Prefs can be found in %userprofile%\AppData\Local\Packages\[ProductPackageId]>\LocalState\playerprefs.dat
On Windows Phone 8, Player Prefs can be found in application’s local folder, See Also: Directory.localFolder
On Android data is stored (persisted) on the device. The data is saved in SharedPreferences. C#/JavaScript, Android Java and Native code can all access the PlayerPrefs data. The PlayerPrefs data is physically stored in /data/data/pkg-name/shared_prefs/pkg-name.xml.
В Mac OS X параметры игрока (player prefs) хранятся в папке
On iOS, PlayerPrefs are stored in /Library/Preferences/[bundle identifier].plist.
Где находятся данные PlayerPrefs в проекте?
По какому пути можно найти значения PlayerPrefs в проекте?
PlayerPrefs никак не привязан к проекту/билду, записи хранятся в разных местах на разных ОС:
macOS, PlayerPrefs are stored in
Windows, PlayerPrefs are stored in the registry under HKCU\Software\[company name]\[product name]
Linux, PlayerPrefs can be found in
Windows Store Apps, Player Prefs can be found in %userprofile%\AppData\Local\Packages\[ProductPackageId]>\LocalState\playerprefs.dat
Windows Phone 8, Player Prefs can be found in application’s local folder
Android, data is stored (persisted) on the device. The data is saved in SharedPreferences. C#/JavaScript, Android Java and Native code can all access the PlayerPrefs data. The PlayerPrefs data is physically stored in /data/data/pkg-name/shared_prefs/pkg-name.xml
WebGL, PlayerPrefs are stored using the browser’s IndexedDB API
iOS, PlayerPrefs are stored in /Library/Preferences/[bundle identifier].plist
PlayerPrefs
`PlayerPrefs` – это класс, в котором хранятся предпочтения игрока между игровыми сессиями. Он может хранить строковые, плавающие и целочисленные значения в реестре платформы пользователя.
Unity хранит данные PlayerPrefs по-разному в зависимости от операционной системы, в которой работает приложение. В путях к файлам, указанных на этой странице, название компании и название продукта — это имена, которые вы задали в настройках проигрывателя Unity.
Место хранения отдельного проигрывателя
В macOS PlayerPrefs хранятся в
/Library/Preferences/com.ExampleCompanyName.ExampleProductName.plist . Unity использует один и тот же файл .plist для проектов в редакторе и автономных проигрывателях.
В Windows PlayerPrefs хранятся в ключе HKCU\Software\ExampleCompanyName\ExampleProductName .
В Linux PlayerPrefs хранятся в
В приложениях Магазина Windows PlayerPrefs хранятся в %userprofile%\AppData\Local\Packages\[ProductPackageId]\LocalState\playerprefs.dat .
В Windows Phone 8 Unity хранит данные PlayerPrefs в локальной папке приложения. Дополнительную информацию см. в разделе Directory.localFolder.
На Android PlayerPrefs хранятся в /data/data/pkg-name/shared_prefs/pkg-name.v2.playerprefs.xml . Unity хранит данные PlayerPrefs на устройстве в SharedPreferences. C#, JavaScript, Android Java и собственный код могут получить доступ к данным PlayerPrefs.
В WebGL Unity хранит данные PlayerPrefs с помощью IndexedDB API браузера. Дополнительную информацию см. в разделе IndexedDB.
Место хранения для режима воспроизведения в редакторе
В macOS PlayerPrefs хранятся в /Library/Preferences/[идентификатор пакета].plist .
В Windows PlayerPrefs хранятся в ключе HKCU\Software\Unity\UnityEditor\ExampleCompanyName\ExampleProductName . Windows 10 использует имена PlayerPrefs приложения. Например, Unity добавляет строку DeckBase и преобразует ее в DeckBase_h3232628825. Приложение игнорирует расширение.
Unity хранит PlayerPrefs в локальном реестре без шифрования. Не используйте данные PlayerPrefs для хранения конфиденциальных данных.