cocos icon
    English
resource-icon
protobuf-creator v1.2.1
Category
Creator Extension Plugins
Author
Devman
Creator Version Required
v3.0.0
Supported Platform
AndroidiOSHTML5
Rating
Sale Price
$ 1.41 (Individual)

Introduction

Introduction

Protobuf creator is a small tool based on protobufjs library, aiming at typescript language, which can easily and quickly generate protobuf static files

Features

  • Creating static javascript files and typescript's tds files
  • Reduce the file size by adjusting the include method of the generated files
  • Recursively read the qualified proto definition file in the specified directory
  • Monitor the changes of files in the specified directory, so as to update the generated files in real time

Operation Steps

  1. Import the protobufjs library as a plugin and accept the loading in the Editor Enviroment.
  2. Select the directory of proto files and run.
  3. Call the protobuf static file's encode and decode method in your typescript files.

Sample

  • test.proto
syntax = "proto3";

package test;

message Say {
    int32 i32 = 1;
    int64 i64 = 2;
    string str = 3;
}
  • test.ts
export default class Test extends cc.Component {

    start () {
        //encoding
        const msg = test.Say.encode({str: "hello world", i64: 100, i32: 10}).finish();
        console.log(msg);
        //decoding
        const hello = test.Say.decode(msg);
        console.log(hello);
    }
}

Dependent Enviroment

  • nodejs

Contact the author

User Rating

Average Rating
(5)
Total users participating at this score: 2

Reviews

zzt0123 2021-11-30 15:13

The code generator has deoptimised the styling of undefined as it exceeds the max of 500KB. 生成的d.ts 超出文件最大限制了 请问有办法单个proto生成单个类和d.ts 吗?

Author

我查看protobuf的官方文档并没有找到相关设置,看来你只能把proto文件拆开编写或者你再查查看是否有其他解决方案

imeka 2021-11-11 17:33

map类型是不是不能用? 编码或解码出来的对象都是空的

Author

https://www.npmjs.com/package/protobufjs 官方文档里已经列了支持的类型

zzt0123 2021-11-09 16:06

请问 google.protobuf.Any类型怎么解析的

Author

这个插件的功能是导入protobufjs库,生成文件步骤也是调用的protobufjs库,并未做自定义解析

mingzx3 2021-10-10 13:13

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' 按照步骤设置库文件为插件,但是一运行就报这个错误

Author

把sourcemap关了

whiteleaf 2021-07-14 17:05

cocoscreator 3.2.0 报错 导出的文件protobufECS报错。设不设置导入为插件都报错。 Could not read source map for http://localhost:7456/scripting/x/mods/file/F:/LevelUp/projects/Coco2dCreater/ECS3D/ECS/assets/Script/Third/Proto/protobufECS.proxy.js?cjs&original=.js: Unexpected 404 response from http://localhost:7456/scripting/x/mods/file/F:/LevelUp/projects/Coco2dCreater/ECS3D/ECS/assets/Script/Third/Proto/protobufECS.proxy.js.map: 404 - Not Found

Author

目前3.2版本不太稳定,建议先使用3.0版本

eric_linxin 2021-06-07 16:27

68818008@qq.com

eric_linxin 2021-06-07 16:25

cocos creator 2.2.1引擎的商店找不到你们的插件,哭了

Author

给我留个邮箱,我直接发你

eric_linxin 2021-06-07 16:10

支持creator 2.2.1吗?

Author

要是用2.2.1引擎,你用2D引擎的商店下1.2.0版本

shawngao 2021-04-28 11:45

The code generator has deoptimised the styling of undefined as it exceeds the max of 500KB. 你好。大神,我的proto比较多,导出后 这样提示,该怎么解决。

Author

这个错误是babel 报错,我搜到的信息你参考一下:https://blog.csdn.net/SpicyBoiledFish/article/details/99841129

zpab123 2021-04-08 16:14

我测试过了,用 win10 是正常的,我用win7就是不行, 因此,可能有2个原因: 1、是 windows 版本的问题 2、node.js 版本的问题,我win7的 node.js 是 v8.x 版本的,我win10是 最新版本的 应该是这两个原因中的一个

Author

之前也有人使用win7,我查了没生成ts的原因是没正确执行node命令,所以如果你在win7上有问题的话,可以考虑升级一下node,我开发时使用的版本我记不清了,现在是15.13.0可以正常操作

  • 1
  • 2
  • 3

2020 © Cocos.com版权所有

增值电信业务经营许可证:闽B2-20160169

闽ICP备14002653号-6

闽公网安备 35020302033941号