//实际应用如Socket.Send(LuaStringBuffer buffer)函数发送协议, 在lua中调用Socket.Send(pb_data) //读取协议 Socket.PeekMsgPacket() {return MsgPacket}; lua 中,取协议字节流 MsgPack.data 为 LuaStringBuffer类型 //msg = Socket.PeekMsgPacket() //pb_data = msg.data void Start() { #if UNITY_5 Application.logMessageReceived += ShowTips; #else Application.RegisterLogCallback(ShowTips); #endif new LuaResLoader(); LuaState state = new LuaState(); state.Start(); Bind(state); state.OpenLibs(LuaDLL.luaopen_pb); state.DoString(script); LuaFunction func = state.GetFunction("Encoder"); func.Call(); func.Dispose(); func = null; func = state.GetFunction("Decoder"); func.Call(); func.Dispose(); func = null; state.CheckTop(); state.Dispose(); state = null; }
void Awake() { Instance = this; luaState = new LuaState(); luaState.OpenLibs(LuaDLL.luaopen_pb); LuaBinder.Bind(luaState); LuaCoroutine.Register(luaState, this); }
public static void Init(string mainScript) { if (string.IsNullOrEmpty(mainScript)) throw new System.NullReferenceException("Can't found the main script."); State = new LuaState(); // 增加搜索路径 for (int i = 0; i < globalSearchPaths.Count; ++i) State.AddSearchPath(globalSearchPaths[i]); State.OpenLibs(LuaDLL.luaopen_pb); LuaBinder.Bind(State); State.Start(); State.DoFile(mainScript); }
//实际应用如Socket.Send(LuaStringBuffer buffer)函数发送协议, 在lua中调用Socket.Send(pb_data) //读取协议 Socket.PeekMsgPacket() {return MsgPacket}; lua 中,取协议字节流 MsgPack.data 为 LuaStringBuffer类型 //msg = Socket.PeekMsgPacket() //pb_data = msg.data void Start() { Application.RegisterLogCallback(ShowTips); new LuaResLoader(); LuaState state = new LuaState(); state.Start(); Bind(state); state.OpenLibs(LuaDLL.luaopen_pb); state.DoString(script); LuaFunction func = state.GetFunction("Encoder"); func.Call(); func.Dispose(); func = null; func = state.GetFunction("Decoder"); func.Call(); func.Dispose(); func = null; state.CheckTop(); state.Dispose(); state = null; }