unity中使用protobuf(兼容ios平台)
来源:互联网 发布:数据融合是数据预处理 编辑:程序博客网 时间:2024/05/22 10:35
导出ios平台的注意:把工程设置为.Net 2.0 subset (否则ios平台不能运行)
下载protobuf-net源码http://download.csdn.net/detail/qwezcl/9510727
建立一个新的文件smcs.rsp ,内容是-unsafe
把protobuf-net源码拷贝unity工程中
例子:
using UnityEngine;
using System.Collections;
using System;
using System.IO;
using System.Runtime.InteropServices;
using UnityEngine.UI;
using AOT;
using ProtoBuf;
public class Test2 : MonoBehaviour {
void Start () {
Test test=new Test();
test.id=10;
test.data="ssssss用户家";
byte[] data;
using (MemoryStream ms = new MemoryStream())
{
Serializer.Serialize<Test>(ms, test);
data = new byte[ms.Length];
ms.Position= 0;
ms.Read(data, 0, data.Length);
Debug.Log(data.Length+"-----");
}
using(MemoryStream ms = new MemoryStream()){
ms.Write(data,0,data.Length);
ms.Position = 0;
Test chatMsg = Serializer.Deserialize<Test>(ms);
Debug.Log(chatMsg.data);
Debug.Log(chatMsg.data+chatMsg.id);
}
}
// Update is called once per frame
void Update () {
}
}
[ProtoContract]
public struct Test {
[ProtoMember(1)]
public int id;
[ProtoMember(2)]
public string data;
// public List<String> data
// {
// get;
// set;
// }
}
- unity中使用protobuf(兼容ios平台)
- unity中使用protobuf(兼容ios平台)
- Unity跨iOS、Android平台使用protobuf-net的方法
- Unity中使用Protobuf
- Unity中使用Protobuf-net
- iOS中从零开始使用protobuf
- iOS中从零开始使用protobuf
- Unity中为什么使用protobuf以及使用方法
- Unity 使用 Protobuf-net
- Unity使用protobuf
- unity 简单使用protobuf
- [Unity 网络]Unity Protobuf使用
- protobuf在iOS中得使用
- iOS中protobuf 的安装和使用
- 【protobuf】 2.在Unity中引用ProtoBuf
- 如何在unity中使用protobuf工具生成cs类
- Unity中protobuf的使用方法
- Unity中protobuf的使用方法
- C - Tanya and Toys
- C++10进制字符串与十六进制字符串相互转化
- 【SignalR-支持平台】
- 《java入门第一季》之面向对象面试题(继承中构造方法的关系)
- 【HUSTOJ】1036: 欧拉函数
- unity中使用protobuf(兼容ios平台)
- 【西西学FPGA】Lesson1
- 绝对定位
- CentOS6.4升级python2.6.6到3.3.0
- 【西西学FPGA】Lesson2
- Swift笔记-让你2小时学会Swift
- Jmeter结果各参数含义
- 【USACO题库】1.3.3 Calf Flac(manacher马拉车算法)
- UiAutomator Android 的自动测试框架(UiAutomator 快速调试)