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

    xiaoxiao2021-04-14  38

     环境:

    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 点击生成

    转载请注明原文地址: https://ju.6miu.com/read-670231.html

    最新回复(0)