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 ...
随机推荐
- <转>大白菜的后门
转自360论坛
- mac系统中搭建apache+mysql+php的开发环境,安装mysql后,登录报错:mac ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
php新手在mac系统中搭建apache+mysql+php的开发环境(按照这篇博客来操作的:http://my.oschina.net/joanfen/blog/171109?fromerr=xvC ...
- 工作总结 input 限制字数 textarea限制字数
最大能输入50个字 复制粘贴也不行 <textarea maxlength="50" class=" smallarea" cols="60& ...
- 将 ASP.NET Core 2.0 项目升级至 ASP.NET Core 2.1
主要升级步骤如下: 将 .csproj 项目文件中的 target framework 改为 netcoreapp2.1 <TargetFramework>netcoreapp2.1< ...
- 用nw.js开发markdown编辑器-已完成功能介绍
这里文章都是从个人的github博客直接复制过来的,排版可能有点乱. 原始地址 http://benq.im/2015/10/29/hexomd-introduction 文章目录 1. 功能列表 ...
- C++语言基础(14)-typeid
typeid可用来判断类型是否相等: 例如有下面的定义: char *str; ; ; float f; 类型比较 结果 类型比较 结果 typeid(int) == typeid(int) true ...
- mysql官网下载页面
http://dev.mysql.com/downloads/mysql/5.6.html#downloads
- nginx源码学习_数据结构(ngx_str_t)
nginx中关于字符串的数据结构位于src/core/ngx_string.c和src/core/ngx_string.h中 先来看一下数据结构: typedef struct { size_t le ...
- 做前端(单纯页面和js)遇到的问题辑录(一)
html标签的name和id的值一样,jQuery在选择的时候会混乱么? 1.超链接<a href="http://www.jb51.net" title="脚本之 ...
- linux命令 — lsof 查看进程打开那些文件 或者 查看文件给那个进程使用
lsof命令是什么? 可以列出被进程所打开的文件的信息.被打开的文件可以是 1.普通的文件,2.目录 3.网络文件系统的文件,4.字符设备文件 5.(函数)共享库 6.管道,命名管道 7.符号链 ...