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 ...
随机推荐
- 神奇的canvas——点与线绘制的绚丽动画效果
代码地址如下:http://www.demodashi.com/demo/11636.html 前言 之前在某网站上看到了一个canvas绘制的动画效果,虽然组成的元素很简单,只有点和线,但是视觉效果 ...
- Java 连接使用 Redis
1. 开始在 Java 中使用 Redis 前, 我们需要确保已经安装了 redis 服务及 Java redis 驱动,且你的机器上能正常使用 Java. 首先你需要下载驱动包,下载 jedis.j ...
- Log4j介绍,log4j.properties配置详解
http://www.cnblogs.com/simle/archive/2011/09/29/2195341.html本文主要解释log4j的配置文件各个配置项的含义,内容是从网上转载的 1.Log ...
- Jenkins插件开发资料
原文地址:http://www.ciandcd.com/?p=181 Jenkins plugin 开发: Document http://hudson-ci.org/docs/index.html ...
- Unlink of file 'xx' failed. Should I try again? (y/n) 解决办法
Unlink of file 'xx' failed. Should I try again? (y/n) 原因:一般遇到这个错输入y/n都不能解决问题,出现这个问题的原因可能是其他程序正在操作git ...
- C#绑定事件时使用匿名函数
当使用一些临时的函数 可以预知这些函数基本不会被复用时 可以使用匿名函数简化代码 public static void startCoupons() { //绑定一些事件 userGetCoupon ...
- 我的 Android 学习笔记-Okhttp 的使用(译)
okhttp 已经是非常流行的网络请求库了.网上介绍的文章非常之多,但感觉都不是特别系统.遂想到官方应该有介绍的文档,仔细寻找一番,果然.但可惜是英文的,于是就大致翻译了一下,权当做笔记了. 1.Ca ...
- JAVA代码之RocketMQ生产和消费数据
一.启动RocketMQ [root@master ~]# cat /etc/hosts # Do not remove the following line, or various programs ...
- hiho一下 第四十九周 欧拉路·一
[题目链接]:click here~~ 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描写叙述 小Hi和小Ho近期在玩一个解密类的游戏.他们须要控制角色在一片原始丛林里面探险 ...
- C++语言基础(1)-命名空间
一个中大型软件往往由多名程序员共同开发,会使用大量的变量和函数,当有两个人都同时定义了一个名字相同的全局变量或函数的时候,若是把他们的代码整合在一块编译,此时编译器就会提示变量或函数重复定义,C++为 ...