Unity中使用Google.Protobuf3,获取dll文件


获取Google.Protobuf.dll文件,有两中方式可以获取,如下:

第一种方法:

获取官方的Google.Protobuf源码:

protobuf各个版本下载地址

https://github.com/protocolbuffers/protobuf/tags

 

解压之后

 

 

这时我们要打开Google.Protobuf这个工程,从这里进入,

 

本人是用VS2019,进行操作的,这里要对VS2019版的要进行安装以下的东东

 

 

 

打开工程

 

 

点击生成即可,然后会在Google.Protobuf中的Debug文件夹中生成Google.Protobuf.dll,System.Buffers.dll,System.Memory.dll,System.Runtime.CompilerServices.Unsafe.dll四个dll文件,这四个就是我们需要的,将这四个生成好的dll文件导入到unity中,即可

 

 

第二种方法:

 用VS2019新建项目,选【类库】

 

 

利用VSNuGet包管理器来生成Google.Protobuf

 

生成出来的这几个文件

 

packages\Google.Protobuf.3.17.0\lib\net45\Google.Protobuf.dll

packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll

packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll

packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\ System.Runtime.CompilerServices.Unsafe.dll 

这就生成出来了四个dll文件,Google.Protobuf.dll,System.Buffers.dll,System.Memory.dll,System.Runtime.CompilerServices.Unsafe.dll