转载:http://www.manew.com/thread-100109-1-1.html
 
今天抽时间学习了“Easy Save2”插件,版本v2.6.3  我个人觉得这个插件是做数据存取最好的插件~~可以取代PlayerPrefs。
它不仅可以直接存取PlayerPrefs支持的int、float、string、bool
还包括下图中所有类型
如果不指定位置,数据会存储在Application.persistentDataPath里
你也可以指定它的存储位置 类似下面这样
[C#] 纯文本查看 复制代码
 
1
2
ES2.Save(data, "C:/Users/User/myFile.txt");    // 这里myFile.txt只存储data
ES2.Save(transform.position, "C:/Users/User/myFile.txt?tag=myPosition");   // 在myFile.txt文件里插入key:myPosition对应value:transform.position
transform.position = ES2.Load<Vector3>("C:/Users/User/myFile.txt?tag=myPosition");  //从myFile.txt文件里读取key:myPosition的value
也可以存储到web
[C#] 纯文本查看 复制代码
 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
public IEnumerator UploadMesh(Mesh mesh, string tag)
{
    // Create a URL and add parameters to the end of it.
    string myURL = "http://www.server.com/ES2.php";
    myURL += "?webfilename=myFile.txt&webusername=user&webpassword=pass";
 
    // Create our ES2Web object.
    ES2Web web = new ES2Web(myURL + "&tag=" + tag);
 
    // Start uploading our data and wait for it to finish.
    yield return StartCoroutine(web.Upload(mesh));
 
    if (web.isError)
    {
        // Enter your own code to handle errors here.
        Debug.LogError(web.errorCode + ":" + web.error);
    }
}
 
public IEnumerator DownloadMesh(string tag)
{
    // Create a URL and add parameters to the end of it.
    string myURL = "http://www.server.com/ES2.php";
    myURL += "?webfilename=myFile.txt&webusername=user&webpassword=pass";
 
    // Create our ES2Web object.
    ES2Web web = new ES2Web(myURL + "&tag=" + tag);
 
    // Start downloading our data and wait for it to finish.
    yield return StartCoroutine(web.Download());
 
    if (web.isError)
    {
        // Enter your own code to handle errors here.
        Debug.LogError(web.errorCode + ":" + web.error);
    }
    else
    {
        // We could save our data to a local file and load from that.
        web.SaveToFile("myFile.txt");
 
        // Or we could just load directly from the ES2Web object.
        this.GetComponent<MeshFilter>().mesh = web.Load<Mesh>(tag);
    }
}
而且在存储和读取基本都是一条命令搞定,很方便。当然数据都是经过加密存储的
需要注意的是在存储Texture时,需要把图片类型改成“Advanced”,并勾选“Read/Write Enabled”
下面给大家分享下我测试的几个类型
[C#] 纯文本查看 复制代码
 
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
  
  
public class SaveTest : MonoBehaviour {
  
    public Image image;
  
    public void Save()
    {
        ES2.Save(123, "IntData");
  
        ES2.Save(1.23f, "FloatData");
  
        ES2.Save(true, "BoolData");
  
        ES2.Save("abc", "StringData");
  
        ES2.Save(new Vector3(10, 20, 30), "Vector3Data");
  
        // 存储transform
        GameObject go = new GameObject();
        go.transform.localPosition = new Vector3(10, 20, 30);
        go.transform.localScale = new Vector3(3, 3, 3);
        ES2.Save(go.transform, "TransformData");
  
        // 存储数组
        int[] intArray = new int[3] { 3, 2, 1 };
        ES2.Save(intArray, "IntArrayData");
  
        // 存储集合
        List<string> stringList = new List<string>();
        stringList.Add("stringlist1");
        stringList.Add("stringlist2");
        stringList.Add("stringlist3");
        ES2.Save(stringList, "StringListData");
  
        // 存储字典
        Dictionary<int, string> stringDict = new Dictionary<int, string>();
        stringDict.Add(1, "a");
        stringDict.Add(2, "b");
        ES2.Save(stringDict, "StringDictData");
  
        // 存储栈
        Stack<string> stringStack = new Stack<string>();
        stringStack.Push("aaa");
        stringStack.Push("bbb");
        ES2.Save(stringStack, "StringStackData");
  
        ES2.SaveImage(image.sprite.texture, "MyImage.png");
    }
  
    public void Load()
    {
        int loadInt = ES2.Load<int>("IntData");
        Debug.Log("读取的int:" + loadInt);
  
        float loadFloat = ES2.Load<float>("FloatData");
        Debug.Log("读取的float:" + loadFloat);
  
        bool loadBool = ES2.Load<bool>("BoolData");
        Debug.Log("读取的bool:" + loadBool);
  
        string loadString = ES2.Load<string>("StringData");
        Debug.Log("读取的string:" + loadString);
  
        Vector3 loadVector3 = ES2.Load<Vector3>("Vector3Data");
        Debug.Log("读取的vector3:" + loadVector3);
  
        Transform loadTransform = ES2.Load<Transform>("TransformData");
        Debug.Log("读取的transform: 坐标" + loadTransform.localPosition + " 缩放" + loadTransform.localScale);
  
        // 读取数组格式存储
        int[] loadIntArray = ES2.LoadArray<int>("IntArrayData");
        foreach (int i in loadIntArray)
        {
            Debug.Log("读取的数组:" + i);
        }
  
        // 读取集合格式存储
        List<string> loadStringList = ES2.LoadList<string>("StringListData");
        foreach (string s in loadStringList)
        {
            Debug.Log("读取的集合数据:" + s);
        }
  
        // 读取字典格式存储
        Dictionary<int, string> loadStringDict = ES2.LoadDictionary<int, string>("StringDictData");
        foreach (var item in loadStringDict)
        {
            Debug.Log("读取的字典数据: key" + item.Key + " value" + item.Value);
        }
  
        Stack<string> loadStringStack = ES2.LoadStack<string>("StringStackData");
        foreach (string ss in loadStringStack)
        {
            Debug.Log("读取的栈内数据:" + ss);
        }
  
        Texture2D tex = ES2.LoadImage("MyImage.png");
        Sprite temp = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0, 0));
        image.sprite = temp;
  
        // 判断是否有该存储key
        Debug.Log(ES2.Exists("IntData"));
  
        // 删除存储key
        ES2.Delete("IntData");
    }
  
  
}

附上下载链接:链接:http://pan.baidu.com/s/1gfAd0uJ 密码:3qd1

最好用的数据存储Easy Save2讲解的更多相关文章

  1. Android中数据存储(一)

    国庆没有给国家添堵,没有勾搭妹子,乖乖的写着自己的博客..... 本文将为大家介绍Android中数据存储的五种方式,数据存储可是非常重要的知识哦. 一,文件存储数据 ①在ROM存储数据 关于在ROM ...

  2. Android数据存储五种方式总结

    本文介绍Android平台进行数据存储的五大方式,分别如下: 1 使用SharedPreferences存储数据     2 文件存储数据       3 SQLite数据库存储数据 4 使用Cont ...

  3. android 数据存储Ⅱ

    本章继续讲解在Android开发中,数据的存储与管理.涉及知识点:SQLite,SwipeRefreshLayout控件刷新. 1.功能需求 练习使用SQLite 做一个登录界面,数据库字段包含用户名 ...

  4. 使用SharedPreferences进行数据存储

    使用SharedPreferences进行数据存储 很多时候我们开发的软件需要向用户提供软件参数设置功能,例如我们常用的QQ,用户可以设置是否允许陌生人添加自己为好友.对于软件配置参数的保存,如果是w ...

  5. Android实现数据存储技术

    转载:Android实现数据存储技术 本文介绍Android中的5种数据存储方式. 数据存储在开发中是使用最频繁的,在这里主要介绍Android平台中实现数据存储的5种方式,分别是: 1 使用Shar ...

  6. Base-Android快速开发框架(二)--数据存储之SharedPreferences

    对于App开发者,抽象来说,其实就是将数据以各种各样的方式展示在用户面前以及采集用户的数据.采集用户的数据包括用户的输入.触摸.传感器等,展示的数据通过网络来源于各业务系统,以及用户的 输入数据.在这 ...

  7. 数据存储简单了解(NSUserDefaults)

    数据存储-使用NSUserDefaults 两个类介绍: NSUserDefaults适合存储轻量级的本地数据,比如要保存一个登陆界面的数据,用户名.密码之类的,个人觉得使用NSUserDefault ...

  8. Android数据存储三剑客——SharedPreferences、File、SQLite

    Android中常用的数据存储一般有三种方式:SharedPreferences.文件和SQLite数据库,用来保存需要长时间保存的数据.本文将通过几个具体的小实例来讲解这三种方式的具体实现. 数据存 ...

  9. android的数据存储方式

    数据存储在开发中是使用最频繁的,在这里主要介绍Android平台中实现数据存储的5种方式,分别是: 1 使用SharedPreferences存储数据 2 文件存储数据 3 SQLite数据库存储数据 ...

随机推荐

  1. 在iis7.5上部署asp.net mvc5

    部署mvc5跟部署mvc4是一样的,唯一不同的是需要修改一下web.config的配置 在web.config中加入一下节点即可 <system.webServer> <module ...

  2. .NET架构转Java开发必须了解的历史

    终于不在职守在.NET领域 .NET的winform和webform项目也开发了很多了  尤其是WEB领域 从ASP -> ASP.NET 2.0 -> ASP.NET MVC 4.0 - ...

  3. B. Spreadsheets(进制转换,数学)

    B. Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard inp ...

  4. 期待suqingnian.h

    不定期更新,跟着自己的进度走的. 有什么好的东西可以收录的尽管留言 UPD:话说真的没人发现本宝宝的$Martix$类的$operator$打错了么?$qwq$ $2018.7.19$ /*by Qi ...

  5. luoguP4396 [AHOI2013]作业

    https://www.luogu.org/problemnew/show/P4396 简单的莫队+树状数组,但博主被卡常了,不保证代码在任何时候都能AC #include <bits/stdc ...

  6. Python之路Python全局变量与局部变量、函数多层嵌套、函数递归

    Python之路Python全局变量与局部变量.函数多层嵌套.函数递归 一.局部变量与全局变量 1.在子程序中定义的变量称为局部变量,在程序的一开始定义的变量称为全局变量.全局变量作用域是整个程序,局 ...

  7. Python之路系列:面向对象初级:静态属性、静态方法、类方法

    一.静态属性 静态属性相当于数据属性. 用@property语法糖装饰器将类的函数属性变成可以不用加括号直接的类似数据属性. 可以封装逻辑,让用户感觉是在调用一个普通的数据属性. 例子: class ...

  8. EL表达式的语法与应用

    EL(是Expression Language的缩写),使用EL对JSP输出进行优化,可以使得页面结构更加清晰,代码可读性高,也更加便于维护. EL表达式的语法: 语法:$(EL 表达式) $  和 ...

  9. centos安装mysql57

    下载源安装文件 https://dev.mysql.com/downloads/repo/yum/ wget http://repo.mysql.com//mysql57-community-rele ...

  10. Ubuntu系统使用apache部署多个django项目(python4.3)

    /etc/apache2/sites-available/pyweb.conf <VirtualHost *:> ServerName 192.168.1.46 DocumentRoot ...