public void Destroy() { if (luaState != null) { if (UpdateEvent != null) { UpdateEvent.Dispose(); UpdateEvent = null; } if (LateUpdateEvent != null) { LateUpdateEvent.Dispose(); LateUpdateEvent = null; } if (FixedUpdateEvent != null) { FixedUpdateEvent.Dispose(); FixedUpdateEvent = null; } luaState = null; } }
LuaBeatEvent GetEvent(string name) { LuaTable table = luaState.GetTable(name); if (table == null) { throw new LuaException(string.Format("Lua table {0} not exists", name)); } LuaBeatEvent e = new LuaBeatEvent(table); table.Dispose(); table = null; return(e); }
internal void Start() { if (LuaConst.openToLuaLib) { try { UpdateEvent = GetEvent("UpdateBeat"); LateUpdateEvent = GetEvent("LateUpdateBeat"); FixedUpdateEvent = GetEvent("FixedUpdateBeat"); UpdateFunc = luaState.GetFunction("Update"); LateUpdateFunc = luaState.GetFunction("LateUpdate"); FixedUpdateFunc = luaState.GetFunction("FixedUpdate"); } catch (Exception e) { //Destroy(this); Destroy(); } } }