Unity3D——PlayerPrefs 游戏存档
来源:互联网 发布:安畅网络水军平台 编辑:程序博客网 时间:2024/04/30 09:59
unity3d提供了一个用于本地持久化保存与读取的类——PlayerPrefs。在游戏会话中储存和访问游戏存档。这个是持久化数据储存,比如保存游戏记录。
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异常。
Static Functions 静态函数
- DeleteAll Removes all keys and values from the preferences. Use with
caution. 从游戏存档中删除所有key。请谨慎使用。 - DeleteKey Removes key and its corresponding value from the
preferences. 从游戏存档中删除key和它对应的值。 - GetFloat Returns the value corresponding to key in the preference
file if it exists. 如果存在,返回游戏存档文件中key对应的浮点数值。 - GetInt Returns the value corresponding to key in the preference file
if it exists. 如果存在,返回游戏存档文件中key对应的整数值。 - GetString Returns the value corresponding to key in the preference
file if it exists. 如果存在,返回游戏存档文件中key对应的字符串值。 - HasKey Returns true if key exists in the preferences.
如果key在游戏存档中存在,返回true。 - Save Writes all modified preferences to disk. 写入所有修改参数到硬盘。
- SetFloat Sets the value of the preference identified by key.
设置由key确定的浮点数值。 - SetInt Sets the value of the preference identified by key.
设置由key键确定的整数值。 - SetString Sets the value of the preference identified by key.
设置由key确定的字符串值。
- Unity3D——PlayerPrefs 游戏存档
- unity3d--PlayerPrefs 游戏存档
- Unity3D游戏存档之PlayerPrefs的用法
- PlayerPrefs 游戏存档
- PlayerPrefs 游戏存档
- Untiy 游戏存档PlayerPrefs
- Unity PlayerPrefs 游戏存档
- Unity游戏存档-PlayerPrefs类
- 关于游戏存档之PlayerPrefs
- Unity3d使用PlayerPrefs类实现数据存档
- Unity Manual之PlayerPrefs 游戏存档
- Unity 游戏存档 PlayerPrefs类的用法
- Unity 游戏存档 PlayerPrefs类的用法
- Unity 游戏存档 PlayerPrefs类的用法
- 基于PlayerPrefs存档
- unity3d PlayerPrefs
- Unity3D游戏开发游戏读/存档在Unity3D中的实现
- 存档——让我们继续游戏
- 最长无重复字符子串长度_M
- cartogapher 源码分析 (transform)
- 过滤掉List<HashMap<String,Object>>中键值相同的数据!
- 车牌识别技术实现方式及应用场景
- bzoj2746 旅行问题
- Unity3D——PlayerPrefs 游戏存档
- 洛谷 1063
- Unity脚本生命周期流程图
- Texture Packer之Unity使用方法
- cxf linux 无法发布服务,报no binding的问题
- Android Studio SVN的使用
- 二叉树常见问题
- android常见的内存泄漏
- CSS基础(后续)