unity中有一个简单的游戏存档类–playerprefs,这个类有什么作用呢?
PlayerPrefs是Unity3d提供了一个用于数据本地持久化保存与读取的类。工作原理十分简单,就是以key-value的形式将数据保存在本地,然后在代码中可以写入、读取、更新数据。它可以用来储存一些非关键性的数据,尤其是一些没有服务器的单机游戏中,游戏存档、分数排名等都需要用到数据存储,这个时候可以使用playerprefs轻松实现数据存储
需要知道的是,这个类存储的数据是以键值对的形式进行,可以简单的看成是一个字典,同时他也是通过键名来进行读取,当键不存在的时候,返回默认值

对应函数:

#region 程序集 UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// D:\unity2018.2.3\install\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
#endregionusing UnityEngine.Bindings;namespace UnityEngine
{//// 摘要://     Stores and accesses player preferences between game sessions.[NativeHeader("Runtime/Utilities/PlayerPrefs.h")]public class PlayerPrefs{public PlayerPrefs();//// 摘要://     Removes all keys and values from the preferences. Use with caution.[NativeMethod("DeleteAllWithCallback")]public static void DeleteAll();//// 摘要://     Removes key and its corresponding value from the preferences.//// 参数://   key:public static void DeleteKey(string key);//// 摘要://     Returns the value corresponding to key in the preference file if it exists.//// 参数://   key:////   defaultValue:public static float GetFloat(string key, float defaultValue);//// 摘要://     Returns the value corresponding to key in the preference file if it exists.//// 参数://   key:////   defaultValue:public static float GetFloat(string key);//// 摘要://     Returns the value corresponding to key in the preference file if it exists.//// 参数://   key:////   defaultValue:public static int GetInt(string key, int defaultValue);//// 摘要://     Returns the value corresponding to key in the preference file if it exists.//// 参数://   key:////   defaultValue:public static int GetInt(string key);//// 摘要://     Returns the value corresponding to key in the preference file if it exists.//// 参数://   key:////   defaultValue:public static string GetString(string key, string defaultValue);//// 摘要://     Returns the value corresponding to key in the preference file if it exists.//// 参数://   key:////   defaultValue:public static string GetString(string key);//// 摘要://     Returns true if key exists in the preferences.//// 参数://   key:public static bool HasKey(string key);//// 摘要://     Writes all modified preferences to disk.[NativeMethod("Sync")]public static void Save();//// 摘要://     Sets the value of the preference identified by key.//// 参数://   key:////   value:public static void SetFloat(string key, float value);//// 摘要://     Sets the value of the preference identified by key.//// 参数://   key:////   value:public static void SetInt(string key, int value);//// 摘要://     Sets the value of the preference identified by key.//// 参数://   key:////   value:public static void SetString(string key, string value);}
}

函数作用就是英文释义。

最后一个事情,这个类保存的数据存在哪里,这里简单的说几个平台
1.MacOS平台下,储存在~/Library/Preferences文件夹,名为unity.[company name].[product name].plist。
2.在windows平台,存储在注册表的 HKEY_CURRENT_USER\Software[company name][product name]键下。

unity游戏存档playerprefs相关推荐

  1. Unity游戏存档-PlayerPrefs类

    对于游戏存档除了XML,Json,Sqlite,unity提供了一个类可以用来存储数据,那就是PlayerPrefs. 这个类对应的API如下 Class Functions类函数 SetInt Se ...

  2. unity 游戏存档

    对于简单的存档,可以利用Playerpref永久保存,通过保存游戏角色的位置来实现,然后当点击继续游戏时通过start初始化得到保存的数据,重新开始游戏则不读取数据.大体思路如下:界面上有退出游戏按钮 ...

  3. Untiy 游戏存档PlayerPrefs

    PlayerPrefs 游戏存档 Description 描述 在游戏会话中储存和访问游戏存档.这个是持久化数据储存,比如保存游戏记录. Editor/Standalone 编辑器 / 桌面平台 Ma ...

  4. Unity游戏存档的四种方式

    [转载]http://blog.csdn.net/a237653639/article/details/50076755 游戏存档 在Unity中游戏存档有如下四种方式: PlayerPrefs c# ...

  5. Unity游戏存档与读档

    目前unity常见存档和读档有几种方式,也就是常见的存储数据的方式(注意存档和读档都是针对单机游戏而言的,角色信息,道具信息,关卡情况等) Unity存档的方式大概分为这两大类 图片来源自siki学院 ...

  6. Unity 游戏存档框架实现

    最近重构了一下我的存档框架.我在这里对实现方法进行简单的解析.注意这里主要演示算法,所以,效率上并不是最佳.一个游戏中,可能有成百上千个物体需要存储,而且有几十种类型,接下来就用一个简单的例子来解释. ...

  7. Unity游戏存档 (将游戏数据储存至本地文档)

    在Unity中 添加本地文档储存游戏数据 首先我们应该在Unity中创建一个C#脚本,将其命名为Inventory 脚本不用挂在任何物体上,只需要在命名空间之前写一句代码,如下: 代码写好之后保存,在 ...

  8. unityplayerpre存档_c# unity PlayerPrefs 游戏存档,直白点就是讲游戏数据本地保存下来...

    在游戏会话中储存和访问游戏存档.这个是持久化数据储存,比如保存游戏记录. 我的理解是通过某个特殊的标签来保存在本地,而且该标签为key的意思,初始值不用赋值. 在游戏开发中较为实用. 暂时用到了 Se ...

  9. c# unity PlayerPrefs 游戏存档,直白点就是讲游戏数据本地保存下来

    在游戏会话中储存和访问游戏存档.这个是持久化数据储存,比如保存游戏记录. 我的理解是通过某个特殊的标签来保存在本地,而且该标签为key的意思,初始值不用赋值. 在游戏开发中较为实用. 暂时用到了 Se ...

最新文章

  1. #180111mysql启动错误
  2. 白帽渗透测试的36条军规
  3. python进阶学啥书籍_2018年Python学习进阶书籍推荐
  4. [ An Ac a Day ^_^ ] CodeForces 691F Couple Cover 花式暴力
  5. 2016 China Joy抢先看,文末有彩蛋!
  6. linux 统计当前目录下文件或者文件夹的数量
  7. Servlet 数据库访问
  8. SQLi LABS Less-18
  9. 7-1 查找整数 (10 分)
  10. python写入文件不覆盖_Python第7课:不一样的新建文件
  11. 到目前为止,Linux下最完整的Samba服务器配置攻略
  12. 一些常见文件加密软件的破解方法
  13. 二叉树遍历之递归与非递归遍历
  14. 【可收藏】3W字,Docker 从入门到精通
  15. Larval Excel导入
  16. 企业邮箱登录入口有哪些?
  17. Double的compareTo
  18. android 内部 存储空间不足,安卓手机内存空间不足的解决方法
  19. 服务器io测试工具-fio
  20. 移芯平台EC616上按键唤醒

热门文章

  1. 【leetcode】771. 宝石与石头 (简单)
  2. SEO人员,做好SEO的三大要素有哪些?
  3. sql多维度组合排序
  4. 知名电商购物车架构流程图
  5. 手机html流星雨代码,流星雨(示例代码)
  6. 神经风格迁移综述论文分享(neural style transfer review)
  7. php 获取手机屏幕宽度,Swift-使用UIScreen类获取屏幕尺寸
  8. AutoJs7打包薅羊毛时间版
  9. CMake中执行shell命令之execute_process、add_custom_target和add_custom_command
  10. [MATLAB]常微分方程数值求解(ode45 ode15s ode23 solver)