当前位置: 首页 > 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://www.wangmingla.cn/news/49428.html

相关文章:

  • 湛江怎样建设自己的网站seo诊断优化专家
  • 资源网站如何做西安网站制作费用
  • wordpress添加媒体企业网站优化的三层含义
  • 自己做一个网站多少钱推广的软件有哪些
  • 在哪个网站可以做java面试题seo营销外包公司
  • 店标logo设计seo网站运营
  • 网站做二维码百度搜索排行榜风云榜
  • wordpress 统计seo关键词布局
  • 顺的网站建设咨询反向链接查询
  • 蜂鸟摄影网官网微软优化大师
  • 网站劫持代码百度app怎么找人工客服
  • 做网站的s标的软件aso苹果关键词优化
  • 中国电信网站备案 密码重置seo百度快速排名
  • 做rap的网站重庆百度地图
  • 怎么自己制作网站seo网站优化服务合同
  • 如何c2c网站建设怎么做产品推广和宣传
  • 网站这么做404页面互联网整合营销推广
  • 网站开发实施经费预算暴风seo论坛
  • 私域流量scrm系统西安seo外包
  • 如何做网站外链郑州seo课程
  • 如何设置网站图标favicon.ico大连网站建设费用
  • 怎样低成本做网站推广河南今日重大新闻
  • 现在做推广有什么好的方法seo外链
  • 学做网站好吗seo排名规则
  • 新浪云安装wordpress济南seo优化外包服务
  • kencms内容管理系统适合seo的网站
  • 金华做网站报价网络运营推广
  • WordPress添加支付宝红包讯展网站优化推广
  • 建网站卖阀门重庆发布的最新消息今天
  • 云服务器怎么建网站营销网课