在Unity.ulua环境下如何生成lua的protobuf文件

来源:互联网 发布:想给自己淘宝店铺刷单 编辑:程序博客网 时间:2024/05/17 01:04

 环境:

1. Unity 5.6

2. Lua: tolua# 1.0.6.293

   使用的LuaFramework_UGUI插件  https://github.com/jarjin/LuaFramework_UGUI

3.ProtoBuf               https://github.com/google/protobuf

4.protoc-gen-lua    https://github.com/sean-lin/protoc-gen-lua

5.ProtoC   https://github.com/google/protobuf/releases

6.Python 自行下载 并且配置环境变量

在各种更新到本地之后开始了以下的操作:


1. 把Protoc放到protobuf/src下

2. cmd进入到protobuf/python 执行以下命令

python setup.py build
python setup.py install

3 进入protoc-gen-lua/plugin 下面 新建一个protoc-gen-lua.bat 把以下内容填写进去,星号为protoc-gen-lua的路径

@python ****\protoc-gen-lua\plugin\protoc-gen-lua

注:

在每个protoc-gen-lua生成的lua文件里, 都有一行

local protobuf = require "protobuf"

本身按照官方出的没问题, 但是在ulua的目录里, 总是报protobuf找不到的错误. 前后对比了下我生成的lua和ulua官方生成的代码里

发现居然他修改了地址改为了

local protobuf = require "protobuf/protobuf"

好吧, 只有修改生成器代码protoc-gen-lua\plugin\protoc-gen-lua中第412行改为

lua('local protobuf = require "protobuf/protobuf"\n')


4. 进入Unity Packager.cs BuildProtobufFile函数

dir 修改为proto文件路径

protoc修改为 protobuf/src/protoc.exe

protoc_gen_dir 修改为protoc-gen-lua.bat的路径

5 unity 菜单LuaFramework/Build Protobuf-lua-gen File 点击生成

0 0
原创粉丝点击