PlayerPrefs
class in UnityEngine
Description
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
class in UnityEngine
Success!
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 try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Description
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.
On WebGL, PlayerPrefs are stored using the browser’s IndexedDB API.
Static Functions
DeleteAll | Removes all keys and values from the preferences. Use with caution. |
DeleteKey | Removes key and its corresponding value from the preferences. |
GetFloat | Returns the value corresponding to key in the preference file if it exists. |
GetInt | Returns the value corresponding to key in the preference file if it exists. |
GetString | Returns the value corresponding to key in the preference file if it exists. |
HasKey | Returns true if key exists in the preferences. |
Save | Writes all modified preferences to disk. |
SetFloat | Sets the value of the preference identified by key. |
SetInt | Sets the value of the preference identified by key. |
SetString | Sets the value of the preference identified by key. |
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.
Copyright © 2017 Unity Technologies. Publication: 5.6-001N. Built: 2017-07-12.
PlayerPrefs
class in UnityEngine
Успех!
Благодарим вас за то, что вы помогаете нам улучшить качество документации по Unity. Однако, мы не можем принять любой перевод. Мы проверяем каждый предложенный вами вариант перевода и принимаем его только если он соответствует оригиналу.
Ошибка внесения изменений
По определённым причинам предложенный вами перевод не может быть принят. Пожалуйста попробуйте снова через пару минут. И выражаем вам свою благодарность за то, что вы уделяете время, чтобы улучшить документацию по Unity.
Описание
Stores and accesses player preferences between game sessions.
Editor/Standalone
В Mac OS X параметры игрока (player prefs) хранятся в папке
/Library/Preferences , HKCU
Software
[company name]
[product name] key, где «company name» и «product name» являются The same .plist file is used for both Projects run in the Editor and standalone players.
В Mac OS X параметры игрока (player prefs) хранятся в папке
/Library/Preferences , HKCU\Software\[company name]\[product name] key, where company and product names are именами указанными в настройках проекта.
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: Windows.Directory.localFolder
On Android data is stored (persisted) on the device. The data is saved in SharerPreferences. 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.
WebPlayer
On Web players, PlayerPrefs are stored in binary files in the following locations:
Mac OS X:
Windows: %APPDATA%\Unity\WebPlayerPrefs
В Mac OS X параметры игрока (player prefs) хранятся в папке
There is one preference file per Web player URL and the file size is limited to 1 megabyte. If this limit is exceeded, SetInt, SetFloat and SetString will not store the value and throw a PlayerPrefsException.
PlayerPrefs
class in UnityEngine
Success!
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 try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Description
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.
On WebGL, PlayerPrefs are stored using the browser’s IndexedDB API.
On iOS, PlayerPrefs are stored in /Library/Preferences/[bundle identifier].plist.
Static Methods
DeleteAll | Removes all keys and values from the preferences. Use with caution. |
DeleteKey | Removes key and its corresponding value from the preferences. |
GetFloat | Returns the value corresponding to key in the preference file if it exists. |
GetInt | Returns the value corresponding to key in the preference file if it exists. |
GetString | Returns the value corresponding to key in the preference file if it exists. |
HasKey | Returns true if key exists in the preferences. |
Save | Writes all modified preferences to disk. |
SetFloat | Sets the value of the preference identified by key. |
SetInt | Sets the value of the preference identified by key. |
SetString | Sets the value of the preference identified by key. |
Did you find this page useful? Please give it a rating:
PlayerPrefs
class in UnityEngine
Success!
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 try again 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` data differently based on which operating system the application runs on. In the file paths given on this page, the company name and product name are the names you set in Unity’s Player Settings.
Standalone Player storage location
On macOS, PlayerPrefs are stored in
/Library/Preferences/com.ExampleCompanyName.ExampleProductName.plist . Unity uses the same .plist file for projects in the Editor and standalone Players.
On Windows, PlayerPrefs are stored in HKCU\Software\ExampleCompanyName\ExampleProductName key.
On Linux, PlayerPrefs are stored in
On Windows Store Apps, PlayerPrefs are stored in %userprofile%\AppData\Local\Packages\[ProductPackageId]\LocalState\playerprefs.dat .
On Windows Phone 8, Unity stores PlayerPrefs data in the application’s local folder. See Directory.localFolder for more information.
On Android, PlayerPrefs are stored in /data/data/pkg-name/shared_prefs/pkg-name.v2.playerprefs.xml . Unity stores PlayerPrefs data on the device, in SharedPreferences. C#, JavaScript, Android Java and native code can all access the PlayerPrefs data.
On WebGL, Unity stores PlayerPrefs data using the browser’s IndexedDB API. For more information, see IndexedDB.
In-Editor Play mode storage location
On macOS, PlayerPrefs are stored in /Library/Preferences/[bundle identifier].plist .
On Windows, PlayerPrefs are stored in HKCU\Software\Unity\UnityEditor\ExampleCompanyName\ExampleProductName key. 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.
Unity stores PlayerPrefs in a local registry, without encryption. Do not use PlayerPrefs data to store sensitive data.
Static Methods
DeleteAll | Removes all keys and values from the preferences. Use with caution. |
DeleteKey | Removes the given key from the PlayerPrefs. If the key does not exist, DeleteKey has no impact. |
GetFloat | Returns the value corresponding to key in the preference file if it exists. |
GetInt | Returns the value corresponding to key in the preference file if it exists. |
GetString | Returns the value corresponding to key in the preference file if it exists. |
HasKey | Returns true if the given key exists in PlayerPrefs, otherwise returns false. |
Save | Writes all modified preferences to disk. |
SetFloat | Sets the float value of the preference identified by the given key. You can use PlayerPrefs.GetFloat to retrieve this value. |
SetInt | Sets a single integer value for the preference identified by the given key. You can use PlayerPrefs.GetInt to retrieve this value. |
SetString | Sets a single string value for the preference identified by the given key. You can use PlayerPrefs.GetString to retrieve this value. |
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.
Copyright © 2020 Unity Technologies. Publication Date: 2021-04-11.