当前位置: 首页 > news >正文

Unity关于easySave2 easySave3保存数据的操作;包含EasySave3运行报错的解决

 关于easySave2 easySave3保存数据的操作;包含EasySave3运行报错的解决

 /// 数据存储路径(Easy Save的默认储存位置为:Application.persistentDataPath,为了方便我们可以给它指定储存路径) #region 存储数据/*/// /// 存储数据/// private void SaveData(){ES2.Save(123, dataPath + "IntData");ES2.Save(1.23f, dataPath + "FloatData");ES2.Save(true, dataPath + "BoolData");ES2.Save("abc", dataPath + "StringData");ES2.Save(new Vector3(10, 20, 30), dataPath + "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, dataPath + "TransformData");///< 存储数组int[] intArray = new int[3] { 3, 2, 1 };ES2.Save(intArray, dataPath + "IntArrayData");///< 存储集合List<string> stringList = new List<string>();stringList.Add("stringlist1");stringList.Add("stringlist2");stringList.Add("stringlist3");ES2.Save(stringList, dataPath + "StringListData");///< 存储字典Dictionary<int, string> stringDict = new Dictionary<int, string>();stringDict.Add(1, "a");stringDict.Add(2, "b");ES2.Save(stringDict, dataPath + "StringDictData");///< 存储栈Stack<string> stringStack = new Stack<string>();stringStack.Push("aaa");stringStack.Push("bbb");ES2.Save(stringStack, dataPath + "StringStackData");//保存图片 注意:该图片原文件属性“Advanced: Read/WriteEnable[*]”勾选可读写的// ES2.SaveImage(image.sprite.texture, "MyImage.png");}*/#endregion#region 加载数据/*/// /// 加载数据/// private void LoadData(){int loadInt = ES2.Load<int>(dataPath + "IntData");Debug.Log("读取的int:" + loadInt);float loadFloat = ES2.Load<float>(dataPath + "FloatData");Debug.Log("读取的float:" + loadFloat);bool loadBool = ES2.Load<bool>(dataPath + "BoolData");Debug.Log("读取的bool:" + loadBool);string loadString = ES2.Load<string>(dataPath + "StringData");Debug.Log("读取的string:" + loadString);Vector3 loadVector3 = ES2.Load<Vector3>(dataPath + "Vector3Data");Debug.Log("读取的vector3:" + loadVector3);Transform loadTransform = ES2.Load<Transform>(dataPath + "TransformData");Debug.Log("读取的transform: Position++" + loadTransform.localPosition + " +++Scale++" + loadTransform.localScale);///< 读取数组格式存储int[] loadIntArray = ES2.LoadArray<int>(dataPath + "IntArrayData");foreach (int i in loadIntArray){Debug.Log("读取的数组:" + i);}///< 读取集合格式存储List<string> loadStringList = ES2.LoadList<string>(dataPath + "StringListData");foreach (string s in loadStringList){Debug.Log("读取的集合数据:" + s);}///< 读取字典格式存储Dictionary<int, string> loadStringDict = ES2.LoadDictionary<int, string>(dataPath + "StringDictData");foreach (var item in loadStringDict){Debug.Log("读取的字典数据: key" + item.Key + " value" + item.Value);}Stack<string> loadStringStack = ES2.LoadStack<string>(dataPath + "StringStackData");foreach (string ss in loadStringStack){Debug.Log("读取的栈内数据:" + ss);}///< 读取纹理 注意:该图片原文件属性“Advanced: Read/WriteEnable[*]”勾选可读写的Texture2D tex = ES2.LoadImage("MyImage.png");Sprite temp = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0, 0));//  showImage.sprite = temp;}*/#endregion#region 删除数据/*/// /// 删除数据/// private void DeleteData(){///< 判断是否有该存储keyif (ES2.Exists(dataPath + "IntData")){Debug.Log(ES2.Exists(dataPath + "IntData"));///< 删除存储keyES2.Delete(dataPath + "IntData");}}*/#endregion#region GUI测试用的 UI按钮/*void OnGUI(){if (GUI.Button(new Rect(0, 0, 100, 100), "储存数据")){SaveData();}if (GUI.Button(new Rect(0, 100, 100, 100), "读取数据")){LoadData();}if (GUI.Button(new Rect(0, 200, 100, 100), "删除数据")){DeleteData();}}*/#endregion#region  保存到本地/保存到web:/*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);}
}*/#endregion#region 最新版的easySave3运行会报错,按照以下修改即可:/** private void Start(){if (LoadEvent==LoadEvent.OnStart&&settings!=null){Load();}}*/#endregion#region 读取/保存 音频/*// Get the AudioSource we want to use to play our AudioClip.var source = this.GetComponent<AudioSource>();// Load an AudioClip from the streaming assets folder into our source.source.clip = ES3.LoadAudio(Application.streamingAssetsPath + "/AudioFile.wav");// Play the AudioClip we just loaded using our AudioSource.source.Play();// Get the AudioSource containing our AudioClip.var source = this.GetComponent<AudioSource>();// Save an AudioClip in Easy Save's uncompressed format.ES3.Save<AudioClip>("myAudio", source.clip);// Load the AudioClip back into the AudioSource and play it.source.clip = ES3.Load<AudioClip>("myAudio");source.Play();*/#endregion#region 从Resource加载/*文件必须具有扩展名 例如:.bytes,以便能够从参考资料中加载它// Create an ES3Settings object to set the storage location to Resources.var settings = new ES3Settings();settings.location = ES3.Location.Resources;// Load from a file called "myFile.bytes" in Resources.var myValue = ES3.Load<Vector3>("myFile.bytes", settings);// Load from a file called "myFile.bytes" in a subfolder of Resources.var myValue = ES3.Load<Vector3>("myFolder/myFile.bytes");*/#endregion#region 把 一堆键值数据 保存为string/byte[]/*// Create a new ES3File, providing a false parameter.var es3file = new ES3File(false);// Save your data to the ES3File.es3File.Save<Transform>("myTransform", this.transform);es3File.Save<string>("myName", myScript.name);// etc ...//保存为字符串string fileAsString = es3File.LoadRawString();//保存为 字节数组byte[] fileAsByteArray = es3File.LoadRawBytes().*/#endregion#region 从 字符串/byte[] 读取/** //把字节数组转换成参数// If we're loading from a byte array, simply provide it as a parameter.var es3file = new ES3File(fileAsByteArray, false);// 把字符串转换为参数// 如果我们以字符串的形式加载,首先需要将其转换为字节数组,再把字节数组转换为参数。var es3file = new ES3File((new ES3Settings()).encoding.GetBytes(fileAsString), false);//再对应取出响应的值// Load the data from the ES3File.es3File.LoadInto<Transform>("myTransform", this.transform);//取出该值赋值到自身myScript.name = es3File.Load<string>("myName");   //取出 name// etc ...*/#endregion#region  电子表格/*使用ES3Spreadsheet, Easy Save能够创建电子表格并以CSV格式存储,所有流行的电子表格软件都支持这种格式,包括      Excel、OSX数字和OpenOffice。保存:var sheet = new ES3Spreadsheet();// Add data to cells in the spreadsheet.for(int col=0; col<10; col++){for(int row=0; row<8; row++){sheet.SetCell<string>(col, row, "someData");}}sheet.Save("mySheet.csv");*//*如果要将数据追加到现有的电子表格,请将电子表格的追加变量设置为true。电子表格中的任何行都将被添加到保存到的行末尾。读取:// Create a blank ES3Spreadsheet.var sheet = new ES3Spreadsheet();sheet.Load("spreadsheet.csv");// Output the first row of the spreadsheet to console.for(int col=0; col<sheet.ColumnCount; col++)Debug.Log(sheet.GetCell<int>(col, 0));*/#endregion

相关文章:

Unity关于easySave2 easySave3保存数据的操作;包含EasySave3运行报错的解决

关于easySave2 easySave3保存数据的操作&#xff1b;包含EasySave3运行报错的解决 /// 数据存储路径&#xff08;Easy Save的默认储存位置为&#xff1a;Application.persistentDataPath&#xff0c;为了方便我们可以给它指定储存路径&#xff09; #region 存储数据/*/// /// 存…...

2022年全球软件质量效能大会(QECon上海站)-核心PPT资料下载

一、峰会简介 近年来&#xff0c;以云计算、移动互联网、物联网、工业互联网、人工智能、大数据及区块链等新一代信息技术构建的智能化应用和产品出现爆发式增长&#xff0c;突破了对于软件形态的传统认知&#xff0c;正以各种展现方式诠释着对新型智能软件的定义。这也使得对…...

【python报错】UserWarning: train_labels has been renamed targets

UserWarning: train_labels has been renamed targetswarnings.warn(“train_labels has been renamed targets”) 这是一条 Python 警告信息&#xff0c;它表示 train_labels 这个变量已经被重命名为 targets&#xff0c;在将来的版本中可能会移除 train_labels。因此&#x…...

算法专题四:前缀和

前缀和 一.一维前缀和(模板)&#xff1a;1.思路一&#xff1a;暴力解法2.思路二&#xff1a;前缀和思路 二. 二维前缀和(模板)&#xff1a;1.思路一&#xff1a;构造前缀和数组 三.寻找数组的中心下标&#xff1a;1.思路一&#xff1a;前缀和 四.除自身以外数组的乘积&#xff…...

STM32学习笔记十五:WS2812制作像素游戏屏-飞行射击游戏(5)探索动画之帧动画

本章又是个重要的章节——动画。 动画&#xff0c;本质上时一系列静态的画面连续播放&#xff0c;欺骗人眼产生动画效果。这个原理自打十九世纪电影诞生开始&#xff0c;就从来没变过。 我们的游戏中也需要一些动画效果&#xff0c;比如&#xff0c;被击中时的受伤效果&#…...

期末复习(程序设计)

根据字符出现频率排序 【问题描述】 给定一个字符串 s &#xff0c;根据字符出现的 频率 对其进行降序排序。一个字符出现的频率是它出现在字符串中的次数。 返回已排序的字符串。 频率相同的的字符按ascii值降序排序。 s不包含空格、制表符、换行符等特殊字符。 【输入格…...

html-css-js移动端导航栏底部固定+i18n国际化全局

需求&#xff1a;要做一个移动端的仿照小程序的导航栏页面操作&#xff0c;但是这边加上了i18n国家化&#xff0c;由于页面切换的时候会导致国际化失效&#xff0c;所以写了这篇文章 1.效果 切换页面的时候中英文也会跟着改变&#xff0c;不会导致切换后回到默认的语言 2.实现…...

Ubuntu Linux 入门指南:面向初学者

目录 1. Ubuntu Linux 简介 Ubuntu 的由来 Ubuntu 与其他 Linux 发行版的比较 Debian&#xff1a; Fedora&#xff1a; openSUSE&#xff1a; Arch Linux&#xff1a; Linux Mint&#xff1a; 第二部分&#xff1a;安装 Ubuntu 1. 准备安装 系统需求 创建 Ubuntu 启…...

常见算法面试题目

前言 总结一些常见的算法题目&#xff0c;每一个题目写一行思路&#xff0c;方便大家复习。具体题目的来源是下面的网站。 剑指offer 剑指offe2 leetcode200题 leetcode 100题 leetcode150题 leetcode 75题 文章目录 前言二叉树非递归遍历牛客JZ31 栈的压入、弹出序列 (…...

PiflowX组件-JDBCWrite

JDBCWrite组件 组件说明 使用JDBC驱动向任意类型的关系型数据库写入数据。 计算引擎 flink 有界性 Sink: Batch Sink: Streaming Append & Upsert Mode 组件分组 Jdbc 端口 Inport&#xff1a;默认端口 outport&#xff1a;默认端口 组件属性 名称展示名称默…...

算法导论复习题目

这题需要考虑什么呢&#xff1f; 一换元&#xff0c;二要使用主方法猜出结果&#xff0c;三是证明的时候添加一个低阶项来消除 LC检索 C&#xff08;x&#xff09;是从上帝视角来看的成本 对C(x)的一个估计&#xff1a; 由两个部分组成&#xff0c;就相当于由以往的经验对未来…...

HTTPS协议详解

目录 前言 一、HTTPS协议 1、加密是什么 2、为什么要加密 二、常见加密方式 1、对称加密 2、非对称加密 三、数据摘要与数据指纹 1、数据摘要 2、数据指纹 四、HTTPS加密策略探究 1、只使用对称加密 2、只使用非对称加密 3、双方都使用非对称加密 4、对称加密非…...

菜鸟学习vue3笔记-vue3 router回顾

1、路由router pnpm i vue-router2、创建使用环境 1.src下创建 router文件夹、里面创建index.ts文件 //创建一个路由暴露出去//1.引入createRouter import { createRouter, createWebHistory } from "vue-router";// import Home from ../components/Home.vue//…...

Mybatis枚举类型处理和类型处理器

专栏精选 引入Mybatis Mybatis的快速入门 Mybatis的增删改查扩展功能说明 mapper映射的参数和结果 Mybatis复杂类型的结果映射 Mybatis基于注解的结果映射 Mybatis枚举类型处理和类型处理器 再谈动态SQL Mybatis配置入门 Mybatis行为配置之Ⅰ—缓存 Mybatis行为配置…...

2023 NCTF writeup

CRYPTO Sign 直接给了fx,gx&#xff0c;等于私钥给了&#xff0c;直接套代码&#xff0c;具体可以参考&#xff1a; https://0xffff.one/d/1424 fx [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…...

golang的大杀器协程goroutine

在Golang中&#xff0c;协程&#xff08;Goroutine&#xff09;是轻量级的执行单元&#xff0c;用于实现并发编程。它是Golang语言的重要组成部分&#xff0c;提供了简洁、高效的方式来处理并发任务。 特点&#xff1a; 1&#xff09;轻量级&#xff1a;Go语言的协程是轻量级…...

[Angular] 笔记 9:list/detail 页面以及@Output

1. Output input 好比重力&#xff0c;向下传递数据&#xff0c;list 传给 detail&#xff0c;smart 组件传给 dumb 组件&#xff0c;父组件传给子组件。input 顾名思义&#xff0c;输入数据给组件。 output 与之相反&#xff0c;好比火箭&#xff0c;向上传递数据或事件。ou…...

Linux学习笔记(一)

如果有自己的物理服务器请先查看这篇文章 文章目录 网卡配置Linux基础指令ls:列出目录内容cd(mkdir.rmkdir): 切换文件夹(创建,删除操作)cp:复制文件或目录mv:文件/文件夹移动cat:查看文件vi:文件查看编辑man:查看命令手册more: 查看文件内容less : 查看文件内容 ps: 显示当前进…...

Python 爬虫 教程

python爬虫框架&#xff1a;Scrapyd&#xff0c;Feapder&#xff0c;Gerapy 参考文章&#xff1a; python爬虫工程师&#xff0c;如何从零开始部署ScrapydFeapderGerapy&#xff1f; - 知乎 神器&#xff01;五分钟完成大型爬虫项目 - 知乎 爬虫框架-feapder - 知乎 scrap…...

uniapp原生插件 - android原生插件打包流程 ( 避坑指南一)

【彩带- 避坑知识点】: 当时开发中安卓插件打包成功后&#xff0c;uniapp引用插件aar&#xff0c;用云打包 &#xff0c;总是提示不包含插件。原因是因为module的androidManifest.xml文件没有注册activity。 这一步 很重要&#xff0c;一定要注册。 --------------------------…...

XML Group端口详解

在XML数据映射过程中&#xff0c;经常需要对数据进行分组聚合操作。例如&#xff0c;当处理包含多个物料明细的XML文件时&#xff0c;可能需要将相同物料号的明细归为一组&#xff0c;或对相同物料号的数量进行求和计算。传统实现方式通常需要编写脚本代码&#xff0c;增加了开…...

ssc377d修改flash分区大小

1、flash的分区默认分配16M、 / # df -h Filesystem Size Used Available Use% Mounted on /dev/root 1.9M 1.9M 0 100% / /dev/mtdblock4 3.0M...

高频面试之3Zookeeper

高频面试之3Zookeeper 文章目录 高频面试之3Zookeeper3.1 常用命令3.2 选举机制3.3 Zookeeper符合法则中哪两个&#xff1f;3.4 Zookeeper脑裂3.5 Zookeeper用来干嘛了 3.1 常用命令 ls、get、create、delete、deleteall3.2 选举机制 半数机制&#xff08;过半机制&#xff0…...

[10-3]软件I2C读写MPU6050 江协科技学习笔记(16个知识点)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16...

【决胜公务员考试】求职OMG——见面课测验1

2025最新版&#xff01;&#xff01;&#xff01;6.8截至答题&#xff0c;大家注意呀&#xff01; 博主码字不易点个关注吧,祝期末顺利~~ 1.单选题(2分) 下列说法错误的是:&#xff08; B &#xff09; A.选调生属于公务员系统 B.公务员属于事业编 C.选调生有基层锻炼的要求 D…...

【JavaSE】多线程基础学习笔记

多线程基础 -线程相关概念 程序&#xff08;Program&#xff09; 是为完成特定任务、用某种语言编写的一组指令的集合简单的说:就是我们写的代码 进程 进程是指运行中的程序&#xff0c;比如我们使用QQ&#xff0c;就启动了一个进程&#xff0c;操作系统就会为该进程分配内存…...

为什么要创建 Vue 实例

核心原因:Vue 需要一个「控制中心」来驱动整个应用 你可以把 Vue 实例想象成你应用的**「大脑」或「引擎」。它负责协调模板、数据、逻辑和行为,将它们变成一个活的、可交互的应用**。没有这个实例,你的代码只是一堆静态的 HTML、JavaScript 变量和函数,无法「活」起来。 …...

关于uniapp展示PDF的解决方案

在 UniApp 的 H5 环境中使用 pdf-vue3 组件可以实现完整的 PDF 预览功能。以下是详细实现步骤和注意事项&#xff1a; 一、安装依赖 安装 pdf-vue3 和 PDF.js 核心库&#xff1a; npm install pdf-vue3 pdfjs-dist二、基本使用示例 <template><view class"con…...

C语言中提供的第三方库之哈希表实现

一. 简介 前面一篇文章简单学习了C语言中第三方库&#xff08;uthash库&#xff09;提供对哈希表的操作&#xff0c;文章如下&#xff1a; C语言中提供的第三方库uthash常用接口-CSDN博客 本文简单学习一下第三方库 uthash库对哈希表的操作。 二. uthash库哈希表操作示例 u…...

Pydantic + Function Calling的结合

1、Pydantic Pydantic 是一个 Python 库&#xff0c;用于数据验证和设置管理&#xff0c;通过 Python 类型注解强制执行数据类型。它广泛用于 API 开发&#xff08;如 FastAPI&#xff09;、配置管理和数据解析&#xff0c;核心功能包括&#xff1a; 数据验证&#xff1a;通过…...