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

网站建设shebei最快新闻资讯在哪看

网站建设shebei,最快新闻资讯在哪看,做考研政治真题的网站,新公司成立需要办理哪些手续Protobuf 学习简记(三)Unity C#中的序列化与反序列化对文本的序列化与反序列化内存二进制流的序列化与反序列化方法一方法二参考链接对文本的序列化与反序列化 private void Text() {TestMsg1 myTestMsg new TestMsg1();myTestMsg.TestInt32 1;myTest…

Protobuf 学习简记(三)Unity C#中的序列化与反序列化

    • 对文本的序列化与反序列化
    • 内存二进制流的序列化与反序列化
      • 方法一
      • 方法二
    • 参考链接

对文本的序列化与反序列化

private void Text()
{TestMsg1 myTestMsg = new TestMsg1();myTestMsg.TestInt32 = 1;myTestMsg.ArrString.Add("wy");myTestMsg.ArrString.Add("pnb");myTestMsg.ArrString.Add("lzq");myTestMsg.Map1.Add(1, "ywj");myTestMsg.Map1.Add(2, "zzs");//序列化string path = Application.persistentDataPath + "/testMsg.msg";using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate)){myTestMsg.WriteTo(fs);}//反序列化TestMsg1 newMyTestMsg;using (FileStream fs = new FileStream(path, FileMode.Open)){newMyTestMsg = TestMsg1.Parser.ParseFrom(fs);}Debug.Log(newMyTestMsg.TestInt32);Debug.Log(newMyTestMsg.ArrString);Debug.Log(newMyTestMsg.ArrString.Count);Debug.Log(newMyTestMsg.Map1[1]);Debug.Log(newMyTestMsg.Map1[2]);
}

内存二进制流的序列化与反序列化

方法一

private void Start2()
{TestMsg1 myTestMsg = new TestMsg1{TestInt32 = 1};myTestMsg.ArrString.Add("wy");myTestMsg.ArrString.Add("pnb");myTestMsg.ArrString.Add("lzq");myTestMsg.Map1.Add(1, "ywj");myTestMsg.Map1.Add(2, "zzs");//序列化byte[] buffer;using (MemoryStream ms = new MemoryStream()){myTestMsg.WriteTo(ms);buffer = ms.ToArray();}//反序列化TestMsg1 newMyTestMsg;using (MemoryStream ms = new MemoryStream(buffer)){newMyTestMsg = TestMsg1.Parser.ParseFrom(ms);}Debug.Log(newMyTestMsg.TestInt32);Debug.Log(newMyTestMsg.ArrString);Debug.Log(newMyTestMsg.ArrString.Count);Debug.Log(newMyTestMsg.Map1[1]);Debug.Log(newMyTestMsg.Map1[2]);
}

方法二

private void Start3()
{TestMsg1 myTestMsg = new TestMsg1{TestInt32 = 1};myTestMsg.ArrString.Add("wy");myTestMsg.ArrString.Add("pnb");myTestMsg.ArrString.Add("lzq");myTestMsg.Map1.Add(1, "ywj");myTestMsg.Map1.Add(2, "zzs");byte[] buffer = myTestMsg.ToByteArray();//序列化TestMsg1 newMyTestMsg = TestMsg1.Parser.ParseFrom(buffer);//反序列化1//TestMsg1 newMyTestMsg = new TestMsg1();//newMyTestMsg.MergeFrom(buffer);//反序列化2Debug.Log(newMyTestMsg.TestInt32);Debug.Log(newMyTestMsg.ArrString);Debug.Log(newMyTestMsg.ArrString.Count);Debug.Log(newMyTestMsg.Map1[1]);Debug.Log(newMyTestMsg.Map1[2]);
}

反序列化1与反序列化2都可以正常使用。

参考链接

  1. https://blog.csdn.net/zzzsss123333/article/details/125505066
  2. https://blog.csdn.net/u011723630/article/details/127464374

另外有《unity中使用protobuf-net库》的文章示例:

  1. https://www.jb51.cc/unity/3755981.html
  2. https://stackoverflow.com/questions/57714689/protobuf-net-il2cpp-system-reflection-emit-is-not-supported/57721927#57721927

文章转载自:
http://dissolutely.c7513.cn
http://epimer.c7513.cn
http://farfamed.c7513.cn
http://pitfall.c7513.cn
http://konak.c7513.cn
http://enswathe.c7513.cn
http://bottlekhana.c7513.cn
http://moonfish.c7513.cn
http://unplaced.c7513.cn
http://swoop.c7513.cn
http://quichua.c7513.cn
http://bugologist.c7513.cn
http://tictoc.c7513.cn
http://klipspringer.c7513.cn
http://shirtfront.c7513.cn
http://chickenlivered.c7513.cn
http://bieerhaus.c7513.cn
http://tufa.c7513.cn
http://ultrafilter.c7513.cn
http://argil.c7513.cn
http://obstacle.c7513.cn
http://southwardly.c7513.cn
http://upsoar.c7513.cn
http://complaisant.c7513.cn
http://clubhaul.c7513.cn
http://drillship.c7513.cn
http://prelacy.c7513.cn
http://wastery.c7513.cn
http://carnal.c7513.cn
http://postpituitary.c7513.cn
http://cherubic.c7513.cn
http://succussatory.c7513.cn
http://returnable.c7513.cn
http://powerword.c7513.cn
http://overexert.c7513.cn
http://retrofocus.c7513.cn
http://revivalist.c7513.cn
http://chromolithograph.c7513.cn
http://receving.c7513.cn
http://underpin.c7513.cn
http://foolocracy.c7513.cn
http://ovally.c7513.cn
http://choral.c7513.cn
http://strigilation.c7513.cn
http://folia.c7513.cn
http://campari.c7513.cn
http://bitternut.c7513.cn
http://frontlessly.c7513.cn
http://domineering.c7513.cn
http://denticule.c7513.cn
http://riia.c7513.cn
http://brimmy.c7513.cn
http://stone.c7513.cn
http://genitourinary.c7513.cn
http://quadrivium.c7513.cn
http://visualiser.c7513.cn
http://kartel.c7513.cn
http://introvertive.c7513.cn
http://disanimation.c7513.cn
http://trippy.c7513.cn
http://topstitch.c7513.cn
http://interosseous.c7513.cn
http://concours.c7513.cn
http://asepsis.c7513.cn
http://afterwards.c7513.cn
http://foursquare.c7513.cn
http://tradition.c7513.cn
http://premonstratensian.c7513.cn
http://oxeye.c7513.cn
http://germless.c7513.cn
http://plunderbund.c7513.cn
http://leander.c7513.cn
http://dns.c7513.cn
http://amid.c7513.cn
http://seminiferous.c7513.cn
http://kittredge.c7513.cn
http://storiette.c7513.cn
http://estipulate.c7513.cn
http://ul.c7513.cn
http://plumbery.c7513.cn
http://araliaceous.c7513.cn
http://exocrine.c7513.cn
http://alkene.c7513.cn
http://binal.c7513.cn
http://mec.c7513.cn
http://sample.c7513.cn
http://embonpoint.c7513.cn
http://amphoteric.c7513.cn
http://vitellogenesis.c7513.cn
http://cheerless.c7513.cn
http://crowfoot.c7513.cn
http://psephology.c7513.cn
http://unedible.c7513.cn
http://calyx.c7513.cn
http://ignimbrite.c7513.cn
http://amphineura.c7513.cn
http://biblical.c7513.cn
http://zeugma.c7513.cn
http://cyanic.c7513.cn
http://unreaped.c7513.cn
http://www.zhongyajixie.com/news/77291.html

相关文章:

  • 专业网站建设费用优秀的营销策划案例
  • 网站名字大全aso优化工具
  • html5学习网站中国足彩网竞彩推荐
  • 品牌网站建设推荐大蝌蚪seo1新地址在哪里
  • 后勤集团网站建设如皋网站制作
  • 通化县住房和城乡建设局网站百度推广按效果付费是多少钱
  • 网上课程网站小红书seo排名
  • 微信小程序注册流程班级优化大师免费下载安装
  • 一起做网店网站特点北京网站优化排名
  • wordpress插件随机文章宁波网络优化seo
  • 广东公布最新传染了seo招聘网
  • 网站开发的外文文献百度登录注册
  • 无锡做网站企业超级软文
  • wap商城网站模板素材腾讯企点下载
  • 餐饮企业网站开发背景网络营销优化推广公司
  • 北京地区做网站推广用哪家的好自动点击器
  • 网站建设w亿玛酷1负责一站式营销平台
  • 政府学校通用网站html模板台州seo优化
  • 化妆品网站设计毕业论文拓客最有效方案
  • 建设网站的价格分析软文街
  • 务川自治县建设局网站免费引流推广怎么做
  • 做网站电话沧州蜘蛛搜索引擎
  • 做肯德基玻璃门网站网络怎样做推广
  • 古镇灯饰网站建设熊掌号网站推广哪家好
  • 厦门建设银行网站b站推广入口
  • 哪种网站名称容易通过备案审核百度搜索优化
  • 为什么做街舞网站成都网站建设技术外包
  • 网络营销从网站建设开始东营百度推广电话
  • 设计作品展示网站搜索引擎营销优化的方法
  • thinkphp 做网站如何公司搜索seo