Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
PlayerPrefs 游戏存档
#### Description 描述 在游戏会话中储存和访问游戏存档。这个是持久化数据储存,比如保存游戏记录。 #### Editor/Standalone 编辑器 / 桌面平台 ### Mac OS 在 Mac OS X 上 PlayerPrefs 是存储在~/Library/Preferences 文件夹,名为 unity.[company name].[product name].plist,其中 company name 和 product name 名是在 Project Setting 中设置,.plist 文件可用于编辑器和桌面平台运行。 (打开 Find,按住 Option 键,点击“前往 →“资源库”,就可以找到 Preferences 文件夹。) ### Windows 在 Windows 平台下,PlayerPrefs 被存储在注册表的 HKEY_CURRENT_USER\Software\[company name]\[product name]键下(打开“运行”输入 regedit 打开注册表),其中 company name 和 product name 名是在 Project Setting 中设置。 ### Linux 在 Linux,PlayerPrefs 是储存在~/.config/unity3d/[CompanyName]/[ProductName]。其中 CompanyName 和 ProductName 名是在 Project Setting 中设置 ### Windows Store 在 Windows Store,PlayerPrefs 是储存在 %userprofile%\AppData\Local\Packages\[ProductPackageId]>\LocalState\playerprefs.dat。 ### Windows Phone 在 Windows Phone 8,PlayerPrefs 是储存在应用自己的文件夹,参见:Windows.Directory.localFolder ### WebPlayer 网页 在网页平台,PlayerPrefs 是储存在二进制文件,看下面的对应的各平台位置: Mac OS X: ~/Library/Preferences/Unity/WebPlayerPrefs Windows: %APPDATA%\Unity\WebPlayerPrefs 一个游戏存档文件对应一个 web 播放器 URL 并且文件大小被限制为 1MB。如果超出这个限制,SetInt、SetFloat 和 SetString 将不会存储值并抛出一个 [PlayerPrefsException](../playerprefsexception/playerprefsexception.html "script:unityengine:classes:playerprefsexception:playerprefsexception") 异常。 #### Static Functions 静态函数 | [DeleteAll](../playerprefs/playerprefs.deleteall.html "script:unityengine:classes:playerprefs:playerprefs.deleteall") | Removes all keys and values from the preferences. Use with caution.从游戏存档中删除所有 key。请谨慎使用。 | | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | | [DeleteKey](../playerprefs/playerprefs.deletekey.html "script:unityengine:classes:playerprefs:playerprefs.deletekey") | Removes key and its corresponding value from the preferences.从游戏存档中删除 key 和它对应的值。 | | [GetFloat](../playerprefs/playerprefs.getfloat.html "script:unityengine:classes:playerprefs:playerprefs.getfloat") | Returns the value corresponding to key in the preference file if it exists.如果存在,返回游戏存档文件中 key 对应的浮点数值。 | | [GetInt](../playerprefs/playerprefs.getint.html "script:unityengine:classes:playerprefs:playerprefs.getint") | Returns the value corresponding to key in the preference file if it exists.如果存在,返回游戏存档文件中 key 对应的整数值。 | | [GetString](../playerprefs/playerprefs.getstring.html "script:unityengine:classes:playerprefs:playerprefs.getstring") | Returns the value corresponding to key in the preference file if it exists.如果存在,返回游戏存档文件中 key 对应的字符串值。 | | [HasKey](../playerprefs/playerprefs.haskey.html "script:unityengine:classes:playerprefs:playerprefs.haskey") | Returns true if key exists in the preferences.如果 key 在游戏存档中存在,返回 true。 | | [Save](../playerprefs/playerprefs.save.html "script:unityengine:classes:playerprefs:playerprefs.save") | Writes all modified preferences to disk.写入所有修改参数到硬盘。 | | [SetFloat](../playerprefs/playerprefs.setfloat.html "script:unityengine:classes:playerprefs:playerprefs.setfloat") | Sets the value of the preference identified by key.设置由 key 确定的浮点数值。 | | [SetInt](../playerprefs/playerprefs.setint.html "script:unityengine:classes:playerprefs:playerprefs.setint") | Sets the value of the preference identified by key.设置由 key 键确定的整数值。 | | [SetString](../playerprefs/playerprefs.setstring.html "script:unityengine:classes:playerprefs:playerprefs.setstring") | Sets the value of the preference identified by key.设置由 key 确定的字符串值。 |
da
2022年10月27日 21:37
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码