记一次 Cocos Creator3.x 的 Protobuf 使用
环境
- 安装依赖
1 | $ npm i long |
- tsconfig
1 | { |
- jsconfig
1 | { |
protobuf 协议文件
1 | syntax = "proto3"; |
1 | $ pbjs -t static-module -w commonjs -o ./assets/scripts/Protos/ProtoData.js {your-proto-path}/*.proto |
使用示例
- 直接使用
1 | import { _decorator, Component } from "cc"; |
- 套娃使用
ProtoUtils.ts
1 | import proto from "./ProtoData.js"; |
1 | import { _decorator, Component } from "cc"; |