PlayerPrefs 玩家偏好
Stores and accesses player preferences between game sessions.
在游戏会话中储存和访问玩家偏好设置。
On Mac OS X 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.
在Mac OS X上PlayerPrefs存储在~/Library/PlayerPrefs文件夹,名为unity.[company name].[product name].plist,这里company和product名是在Project Setting中设置的,相同的plist用于在编辑器中运行的工程和独立模式.
On Windows standalone players, 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.
在Windows独立模式下,PlayerPrefs被存储在注册表的 HKCU\Software\[company name]\[product name]键下,这里company和product名是在Project Setting中设置的.
On Web players, PlayerPrefs are stored in binary files under ~/Library/Preferences/Unity/WebPlayerPrefs on Mac OS X and %APPDATA%\Unity\WebPlayerPrefs on Windows. There is one preference file per Web player URL and the file size is limited to 1 megabyte. If this limit would be exceeded, SetInt, SetFloat and SetString will not store the value and throw a PlayerPrefsException.
在Web模式,PlayerPrefs存储在Mac OS X的二进制文件 ~/Library/Preferences/Unity/WebPlayerPrefs中和Windows的 %APPDATA%\Unity\WebPlayerPrefs中,一个偏好设置文件对应一个web播放器URL并且文件大小被限制为1MB。如果超出这个限制,SetInt、SetFloat和SetString将不会存储值并抛出一个PlayerPrefsException。
Class Functions类函数
-
Sets the value of the preference identified by key.
设置由key确定的偏好值。 -
Returns the value corresponding to key in the preference file if it exists.
如果存在,返回偏好文件中key对应的值。 -
Sets the value of the preference identified by key.
设置由key确定的偏好值。 -
Returns the value corresponding to key in the preference file if it exists.
如果存在,返回偏好文件中key对应的值。 -
Sets the value of the preference identified by key.
设置由key确定的偏好值。 -
Returns the value corresponding to key in the preference file if it exists.
如果存在,返回偏好文件中key对应的值。 -
Returns true if key exists in the preferences.
如果key在偏好中存在,返回true。 -
Removes key and its corresponding value from the preferences.
从偏好中删除key和它对应的值。
-
Removes all keys and values from the preferences. Use with caution.
从偏好中删除所有key。请谨慎使用。 -
Writes all modified preferences to disk.
写入所有修改参数到硬盘。