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

 环境:

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
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值