[]如何在laya中直接使用proto中定义的enum?

如何在laya中直接使用proto中定义的enum?

type.proto
enum e_server_msg_type {
e_mst_start_c2g = 300;
e_mst_c2g_heartbeat = 301; //心跳协议
e_mst_c2g_select_gate = 302; //选择网关

e_mst_start_g2c = 400;
e_mst_g2c_select_gate_result = 401;//选择网关返回
e_mst_g2c_send_msglist = 402;//发送协议列表

e_mst_cgend_index = 500;
}
已邀请:

cuixueying

赞同来自:

同原生js使用方式一样,如果你是js项目,直接使用即可!

Zzz18815519

赞同来自:

我用的是ts项目,麻烦详细指教:我获取到root_protocol后如何使用?

let root_protocol:any = null;
function protobufInit(){
    var ProtoBuf:any = Browser.window.protobuf;
    ProtoBuf.load("type.proto", this.onProtoLoaded);
    ProtoBuf.load("Lobby/protobuf/client2world_protocol.proto", this.onProtoBufLoaded1);
}
function onProtoLoaded(err:any, root:any):void{
    if (err)
        throw err;
    root_protocol = root;
}

要回复问题请先

商务合作
商务合作