protobuf參考教程:https://www.jianshu.com/p/b135676dbe8dhtml
手寫.proto文件後,用CMD命令行運行protoc.exe編譯器,進入.proto文件路徑生成C#文件,再把C#文件放到Unity項目中使用。git
插件protobuf-net:http://www.cnblogs.com/xuf22/articles/3504399.htmlgithub
緣由是官方Protobuf的C#實現要求.Net4.6及以上,而Unity使用的.Net太低版本(老版本最高.Net3.5,具體要看是用的Unity的版本)。編輯器
在已寫好的C#實體類中加上打標籤。google
插件protobuf-unity:https://github.com/5argon/protobuf-unityspa
這是Unity編輯器插件。Protobuf正常使用流程是手寫.proto文件後,用CMD命令行運行protoc.exe編譯器,進入.proto文件路徑生成C#文件,再把C#文件放到Unity項目中使用。該插件可自動尋找Unity項目中全部.proto文件並一鍵生成全部對應的C#文件(出如今與每一個.proto文件相同的目錄下)。而且當.proto文件被修改時會自動從新生成C#文件!插件
插件protobuf_for_unity命令行
https://github.com/GongFaxin/protobuf_for_unity 或 https://github.com/bitcraftCoLtd/protobuf3-for-unity3d
命令行使用protoc.exe時,報錯Missing input file。即當前設置的--proto_path目錄下找不到.proto文件。以下圖,protoc.exe與person.proto文件在同一目錄下的。htm