IlRuntime + protobuf-net
环境unity566,.net2.0
下载protobuf-net
https://github.com/mgravell/protobuf-net/tree/r668
因为这个vs2015就可以打开,主干需要2017
下载ILRuntime
https://github.com/Ourpalm/ILRuntime
参照
https://github.com/Ourpalm/ILRuntimeU3D/
搭建1个hotfix工程,1个unity工程,完整工程如下
https://github.com/yingsz/ILRuntime-protobuf-net
遇到的几个问题
1对于hotfix工程里,继承外部类或接口,需要编写adaptor,并注册,网上有教程
2对于hotfix工程不可以既继承外部类,同时又实现外部接口。ProtoMemberAttribute既继承了Attribute,又实现了ICompare.
这个时候需要在外部实现1个类,继承Attribute。并实现接口ICompare,比如叫CompareAttribute,然后ProtoMemberAttribute继续CompareAttribute
但是我简单粗暴的把ICompare删了
3ILRuntime里抛nullreferenceexception,这个是因为protobuf生成文件里
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
获取方法名字是“global::ProtoBuf.IExtensible.GetExtensionObject”,而ILRuntime里用名字找方法是用的是
if (m == null && method.DeclearingType.IsInterface)
{
m = GetMethod(string.Format("{0}.{1}", method.DeclearingType.FullName, method.Name), method.Parameters, genericArguments, method.ReturnType, true);
名字是“ProtoBuf.IExtensible.GetExtensionObject”,所以会找不到方法,所以需要改成
var m = GetMethod(method.Name, method.Parameters, genericArguments, method.ReturnType, true);
if (m == null && method.DeclearingType.IsInterface)
{
m = GetMethod(string.Format("{0}.{1}", method.DeclearingType.FullName, method.Name), method.Parameters, genericArguments, method.ReturnType, true);
if(m == null)
m = GetMethod(string.Format("global::{0}.{1}", method.DeclearingType.FullName, method.Name), method.Parameters, genericArguments, method.ReturnType, true);
}
IlRuntime + protobuf-net的更多相关文章
- python通过protobuf实现rpc
由于项目组现在用的rpc是基于google protobuf rpc协议实现的,所以花了点时间了解下protobuf rpc.rpc对于做分布式系统的人来说肯定不陌生,对于rpc不了解的童鞋可以自行g ...
- Protobuf使用规范分享
一.Protobuf 的优点 Protobuf 有如 XML,不过它更小.更快.也更简单.它以高效的二进制方式存储,比 XML 小 3 到 10 倍,快 20 到 100 倍.你可以定义自己的数据结构 ...
- java netty socket库和自定义C#socket库利用protobuf进行通信完整实例
之前的文章讲述了socket通信的一些基本知识,已经本人自定义的C#版本的socket.和java netty 库的二次封装,但是没有真正的发表测试用例. 本文只是为了讲解利用protobuf 进行C ...
- 在Wcf中应用ProtoBuf替代默认的序列化器
Google的ProtoBuf序列化器性能的牛逼已经有目共睹了,可以把它应用到Socket通讯,队列,Wcf中,身为dotnet程序员一边期待着不久后Grpc对dotnet core的支持更期待着Wc ...
- protobuf的编译安装
github地址:https://github.com/google/protobuf支持多种语言,有多个语言的版本,本文采用的是在centos7下编译源码进行安装. github上有详细的安装说明: ...
- 编译protobuf的jar文件
1.准备工作 需要到github上下载相应的文件,地址https://github.com/google/protobuf/releases protobuf有很多不同语言的版本,因为我们需要的是ja ...
- protobuf学习(2)-相关学习资料
protobuf官方git地址 protobuf官方英文文档 (你懂的需要FQ) protobuf中文翻译文档 protobuf概述 (官方翻译 推荐阅读) protobuf入门 ...
- google protobuf安装与使用
google protobuf是一个灵活的.高效的用于序列化数据的协议.相比较XML和JSON格式,protobuf更小.更快.更便捷.google protobuf是跨语言的,并且自带了一个编译器( ...
- c# (ENUM)枚举组合类型的谷歌序列化Protobuf
c# (ENUM)枚举组合类型的谷歌序列化Protobuf,必须在序列化/反序列化时加上下面: RuntimeTypeModel.Default[typeof(Alarm)].EnumPassthru ...
随机推荐
- ijkPlayer 集成
代码地址如下:http://www.demodashi.com/demo/11957.html 概述 ijkplayer 是一款做视频直播的框架,基于FFmpeg,支持Android和iOS.这里介绍 ...
- MongoDB之索引
索引是用来加快查询的,这里不解说索引的原理和数据结构.事实上大部分数据库的索引就是B+Tree,想要了解的同学能够看索引原理,要掌握怎样为查询配置最佳索引会有些难度. MongoDB索引差点儿和关系型 ...
- http://www.allegro-skill.com/thread-2506-1-1.html
http://www.allegro-skill.com/thread-2506-1-1.html
- vue 父组件如何调用子组件的函数Methods
答案就是使用ref即可. <countdown ref="countdown"></countdown> beforeDestroy () { // 切换页 ...
- hdu 1829 &poj 2492 A Bug's Life(推断二分图、带权并查集)
A Bug's Life Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
- Python 中,matplotlib绘图无法显示中文的问题
在python中,默认情况下是无法显示中文的,如下代码: import matplotlib.pyplot as plt # 定义文本框和箭头格式 decisionNode = dict(boxsty ...
- C/C++知识要点4——printf函数以及cout的计算顺序
printf函数的计算顺序:先从右到左压栈,然后从左到右出栈. 例程: #include"stdio.h" int main() { int arr[] = { 1, 2, 3, ...
- AAC终结者Opus音频编码器的瑞士军刀,编译android ios
AAC-LD/ELD it is either 480 or 512 PCM samples per frame and channel. http://opus-codec.org/download ...
- Java进阶03 IO基础(转载)
IO示例 下面是演示的文件file.txt Hello World! Hello Nerd! 先来研究一个文件读取的例子: import java.io.*;public class Test{ pu ...
- Spring MVC文件上传处理
以下示例显示如何在使用Spring Web MVC框架的表单中上传文件和处理.首先使用Eclipse IDE来创建一个WEB工程,实现一个上传文件并保存的功能.并按照以下步骤使用Spring Web ...