Unity中通过PlayerPrefs进行数据保存
来源:互联网 发布:ubuntu ntfs-3g 编辑:程序博客网 时间:2024/05/16 05:43
在Unity中存储数据也是通过键值对的方式来进行。
主要通过PlayerPrefs来完成。
通过PlayerPrefs可以用来保存和访问玩家的偏好设置。
在Mac OS X中,PlayerPrefs的数据保存在~/Library/Preferences文件夹中,以unity.[company name].[product name].plist来命名。该文件在调试和正常运行中数据共享。
在Windows中,PlayerPrefs的数据保存在注册表HKCU\Software[company name][product name] key中。
在Linux中,PlayerPrefs的数据保存在
~/.config/unity3d/[CompanyName]/[ProductName]中。
类方法
◆ static function DeleteAll(): void
描述:从设置文件中移除所有键和值,谨慎的使用它们。
◆ static function DeleteKey(key: string): void
描述:从设置文件中移除key和它对应的值。
◆ static function GetFloat(key: string, defaultValue: float=OF): float
描述:如果存在,返回设置文件中key对应的值.如果不存在,它将返回defaultValue。
print(PlayerPrefs.GetFlat(“Player score”));
◆ static function GetInt(key: string, defaultValue: int): int
描述:返回设置文件中key对应的值,如果存在.如果不存在,它将返回defaultValue。
print(PlayerPrefs.GetInt(“Player score”));
◆ static function GetString(key: string, defaultValue: string=**): string
描述:返回设置文件中key对应的值,如果存在.如果不存在,它将返回defaultValue.
print(PlayerPrefs.GetString(“Player Name”));
◆ static function HasKey(key: string): bool
描述:在设置文件如果存在key则返回真.
◆ static function SetFloat(key: string, value: float): void
描述:设置由key确定的值.
print(PlayerPrefs.SetFloat(“Player Score”, 10.0));
◆ static function SetInt(key: string, value: int): void
描述:设置由key确定的值.
PlayerPrefs.SetInt(“Player Score”, 10);
◆ static function SetString(key: string, value: string): void
描述:设置由key确定的值.
PlayerPrefs.Setstring(“Player Name”, “Foobar”);
- Unity中通过PlayerPrefs进行数据保存
- Unity PlayerPrefs 保存本地持久化数据
- Unity保存数据方式——PlayerPrefs
- Unity3d 中 PlayerPrefs 保存数据的总结
- Unity退出后保存数据,PlayerPrefs 玩家偏好
- Unity中PlayerPrefs.DeleteAll()无法清除数据的问题
- unity 中playerprefs 会把数据写在什么位置
- unity 简单数据存储PlayerPrefs
- Unity PlayerPrefs.DeleteAll 无效以及 PlayerPrefs文件保存位置
- Unity 3d 保存玩家数据到本地之PlayerPrefs, C#封装
- (8)unity入门,玩家信息保存PlayerPrefs、IO、数据字典
- Unity3D-PlayerPrefs本地数据保存读取
- Unity之数据持久化(PlayerPrefs)
- Unity中的持久化数据PlayerPrefs
- 【Unity】Unity中通过纹理截屏将图片保存到本地
- Unity编程笔录--Unity中Microphone类进行录音保存
- unity中通过SVN进行版本控制
- unity中的playerprefs数据会随打包一同带走吗?
- 【codeforces】数学
- uva 11235 Frequent Values
- python+Eclipse+pydev环境搭建
- 18. 4Sum
- LightOJ 1294 Positive Negative Sign
- Unity中通过PlayerPrefs进行数据保存
- pods 比较经典的文章
- Linux 技巧:让进程在后台可靠运行的几种方法
- spring+springmvc+mybatis+oracle整合开发核心配置代码
- 数据类型
- uvalive 6692 - Lucky Number 水题
- 企业转型是一个自我挑战、自我生长的过程
- H5 Native WebView 交互框架及经验
- Mysql联合索引使用