当前位置: 首页 > 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;一定要注册。 --------------------------…...

Debian系统简介

目录 Debian系统介绍 Debian版本介绍 Debian软件源介绍 软件包管理工具dpkg dpkg核心指令详解 安装软件包 卸载软件包 查询软件包状态 验证软件包完整性 手动处理依赖关系 dpkg vs apt Debian系统介绍 Debian 和 Ubuntu 都是基于 Debian内核 的 Linux 发行版&#xff…...

【机器视觉】单目测距——运动结构恢复

ps&#xff1a;图是随便找的&#xff0c;为了凑个封面 前言 在前面对光流法进行进一步改进&#xff0c;希望将2D光流推广至3D场景流时&#xff0c;发现2D转3D过程中存在尺度歧义问题&#xff0c;需要补全摄像头拍摄图像中缺失的深度信息&#xff0c;否则解空间不收敛&#xf…...

django filter 统计数量 按属性去重

在Django中&#xff0c;如果你想要根据某个属性对查询集进行去重并统计数量&#xff0c;你可以使用values()方法配合annotate()方法来实现。这里有两种常见的方法来完成这个需求&#xff1a; 方法1&#xff1a;使用annotate()和Count 假设你有一个模型Item&#xff0c;并且你想…...

什么是库存周转?如何用进销存系统提高库存周转率?

你可能听说过这样一句话&#xff1a; “利润不是赚出来的&#xff0c;是管出来的。” 尤其是在制造业、批发零售、电商这类“货堆成山”的行业&#xff0c;很多企业看着销售不错&#xff0c;账上却没钱、利润也不见了&#xff0c;一翻库存才发现&#xff1a; 一堆卖不动的旧货…...

HBuilderX安装(uni-app和小程序开发)

下载HBuilderX 访问官方网站&#xff1a;https://www.dcloud.io/hbuilderx.html 根据您的操作系统选择合适版本&#xff1a; Windows版&#xff08;推荐下载标准版&#xff09; Windows系统安装步骤 运行安装程序&#xff1a; 双击下载的.exe安装文件 如果出现安全提示&…...

uniapp微信小程序视频实时流+pc端预览方案

方案类型技术实现是否免费优点缺点适用场景延迟范围开发复杂度​WebSocket图片帧​定时拍照Base64传输✅ 完全免费无需服务器 纯前端实现高延迟高流量 帧率极低个人demo测试 超低频监控500ms-2s⭐⭐​RTMP推流​TRTC/即构SDK推流❌ 付费方案 &#xff08;部分有免费额度&#x…...

智能仓储的未来:自动化、AI与数据分析如何重塑物流中心

当仓库学会“思考”&#xff0c;物流的终极形态正在诞生 想象这样的场景&#xff1a; 凌晨3点&#xff0c;某物流中心灯火通明却空无一人。AGV机器人集群根据实时订单动态规划路径&#xff1b;AI视觉系统在0.1秒内扫描包裹信息&#xff1b;数字孪生平台正模拟次日峰值流量压力…...

网站指纹识别

网站指纹识别 网站的最基本组成&#xff1a;服务器&#xff08;操作系统&#xff09;、中间件&#xff08;web容器&#xff09;、脚本语言、数据厍 为什么要了解这些&#xff1f;举个例子&#xff1a;发现了一个文件读取漏洞&#xff0c;我们需要读/etc/passwd&#xff0c;如…...

android RelativeLayout布局

<?xml version"1.0" encoding"utf-8"?> <RelativeLayout xmlns:android"http://schemas.android.com/apk/res/android"android:layout_width"match_parent"android:layout_height"match_parent"android:gravity&…...

【FTP】ftp文件传输会丢包吗?批量几百个文件传输,有一些文件没有传输完整,如何解决?

FTP&#xff08;File Transfer Protocol&#xff09;本身是一个基于 TCP 的协议&#xff0c;理论上不会丢包。但 FTP 文件传输过程中仍可能出现文件不完整、丢失或损坏的情况&#xff0c;主要原因包括&#xff1a; ✅ 一、FTP传输可能“丢包”或文件不完整的原因 原因描述网络…...