1. 添加 dll
1. 下载 protobuf 源码
根据需要下载 protobuf 指定版本的源码,这里以 v3.21.12(protobuf-csharp-3.21.12.zip)为例:
下载地址:「https://github.com/protocolbuffers/protobuf/releases」
2. 下载 Visual Studio 2022
曾尝试使用 Visual Studio 2021 版本编译,但是会报错,更新版本后,即可编译成功
下载地址:「https://visualstudio.microsoft.com/zh-hans/downloads/」
3. 编译 dll
1. 使用 Visual Studio 2022 打开 protobuf 项目中的 Google.Protobuf.sln
2. 编译模式选择:Release
3. Google.Protobuf 右键选择生成 Google.Protobuf
4. 拷贝 dll
编译生成的 dll 在 csharp/src/Google.Protobuf/bin/Release 目录下
将 net45 目录下所有的 dll 文件拷贝到 Unity 指定目录中
2. proto 转 cs
1. 下载编译器
在 protobuf 源码链接中下载对应的平台的编译器(mac: protoc-21.12-osx-x86_64.zip,windows:protoc-21.12-win64.zip)