【插件发布汇】第二弹 《protobuf creator》方便快捷小工具

我在discord里刚看到你的留言,如有问题通过论坛和discord都可以啊

录一个操作视频给对操作流程不太清楚的朋友@时间与沙,https://www.bilibili.com/video/BV1J54y1Y7KH

我在2.4.6版本,按步骤生成了ts文件,把库文件设置为插件,但是每次运行都会报错
Could not read source map for http://localhost:7456/plugins/assets/plugins/protobuf.min.js: Unexpected 404 response from http://localhost:7456/plugins/assets/plugins/protobuf.min.js.map: Error: ENOENT: no such file or directory, stat 'E:\Diudiupai\assets\plugins\protobuf.min.js.map'

把sourcemap关了

除了关闭sourcemap,还有其他办法吗

用模拟器运行时,会报这个错误

  • Simulator: E/jswrapper (213): ScriptEngine::onGetStringFromFile buffer not found, possible missing file.

  • Simulator: E/jswrapper (300): [ERROR] Failed to invoke require, location: c:\users\nantas\fireball-x\cocos2d-x-lite_245\cocos\scripting\js-bindings\manual\jsb_global.cpp:300

  • Simulator: E/jswrapper (213): ScriptEngine::onGetStringFromFile long not found, possible missing file.

  • Simulator: E/jswrapper (300): [ERROR] Failed to invoke require, location: c:\users\nantas\fireball-x\cocos2d-x-lite_245\cocos\scripting\js-bindings\manual\jsb_global.cpp:300

1赞

我在网上找了一个 protobuf.min.js.map文件放进去,不报错了。但是模拟器运行,还是会报错

在插件的protobuf包里有对应的map文件,模拟器看报错信息你先查查看是读哪个文件报错

  • Simulator: E/jswrapper (213): ScriptEngine::onGetStringFromFile long not found, possible missing file.
    这一条报错,我查到原因了,是因为protobuf里面缺失long类型,我加入long.js,就好了,也不知道对不对。
    剩下一个
  • Simulator: E/jswrapper (213): ScriptEngine::onGetStringFromFile buffer not found, possible missing file.
    我还没有头绪。

你先把sourcemap关了试一试,如果你开启调试的话可能就需要引入多个原文件了

微信图片_20211010235610
我查到一个信息,是说5.0版本没有long和buffer类型,会不会是插件版本的问题

插件带的protobuf版本是6以上的,你可以在插件包里的protobuf包里查到,如果想要指定版本可以自行在插件根目录下安装

在编辑器中,用模拟器运行的时候,long和buffer 找不到
ERROR: Uncaught Error: Failed to require file ‘buffer’, not found!, location: (no filename):0:0
ERROR: Uncaught Error: Failed to require file ‘long’, not found!, location: (no filename):0:0
请问这个怎么解决啊

哥们,我也是在编辑器中,用模拟器运行的时候,long和buffer 找不到

请问你最后是怎么解决的啊


不行哦

请问大佬能否在转proto的逻辑里增加根据协议下标来查找对应的成员数据,比如有个协议
message CmdPlayer{
required int64 playerId = 1;//玩家id
optional string name = 2;//名称
optional int32 icon = 3;//头像
}
后端发来的更新只有这个协议成员的下标(index,例如2)和对应数据的byte,意思后端这时更新的是玩家的名字,就不用再发送整个协议(节省其他没用的空间)

抱歉搞不了哈

推荐一个可以直接导出二进制文件+ts文件的工具,不用在走一遍proto文件了,还开源:

https://github.com/wingcd/go-xlsx-exporter

作者您好,请问这个问题怎么解决?我在点生成后报如下错误:生成ts文件失败,js是ok的
我是用的版本是3.6.2,windows,有正确安装notejs。npm运行成长
[Window] code 1Error: code 1
at ChildProcess. (D:\WorkSpace\PrjNBASquare\Client\PrjNBASquare\extensions\protobuf-creator\node_modules\protobufjs\cli\pbts.js:130:27)
at ChildProcess.emit (events.js:327:22)
at maybeClose (internal/child_process.js:1048:16)
at Process.onexit (internal/child_process.js:288:5)

可以自己写个测试脚本,调用protobuf库的pbts命令去生成dts,插件也是用的这个
const {pbjs, pbts} = require("protobufjs/cli]");
如有错误原因可能有两个1、node命令找不到。2、proto文件编写有问题