Beispiel #1
0
        public void StopSvr()
        {
            if (m_luaSvr == null)
            {
                return;
            }

            if (!m_launched)
            {
                SLua.Logger.LogError("lua虚拟机还没启动完成");
                return;
            }

            Application.logMessageReceived -= UnityLogCallback; //监听unitys的log

            m_luaTable = null;

            m_luaState.loaderDelegate = null;
            m_luaState.Dispose();

            m_luaUpdate      = null;
            m_luaLateUpdate  = null;
            m_luaNotify      = null;
            m_luaNotifyError = null;

            m_luaState = null;
            m_luaSvr   = null;
            m_launched = false;


            LuaEvtCenter.Enable = false;

            //errorDelegateLua = null; //因为是static,由外面自己维护
        }
Beispiel #2
0
        void OnLaunched()
        {
            m_launched = true;
            SLua.Logger.Log("OnSvrLaunched");

            DoBind(m_luaState.L);

            LuaEvtCenter.Enable = true;

            //入口文件可以不叫main,但要有一个global的main方法, 其返回一个含有luaSvr_update等方法的一个表
            m_luaTable = m_luaSvr.start("main") as LuaTable;

            m_luaUpdate     = ((LuaFunction)m_luaTable["luaSvr_update"]).cast <LuaDelegate_Update>();
            m_luaLateUpdate = ((LuaFunction)m_luaTable["luaSvr_lateUpdate"]).cast <LuaDelegate_Update>();
            m_luaNotify     = ((LuaFunction)m_luaTable["luaSvr_notify"]).cast <LuaDelegate_Notify>();
            //m_luaNotify = (LuaFunction)m_luaTable["luaSvr_notify"];
            m_luaNotifyError = ((LuaFunction)m_luaTable["luaSvr_notifyCsError"]).cast <LuaDelegate_NotifyError>();

            Application.logMessageReceived += UnityLogCallback; //监听unitys的log


            LuaFunction luaLaunch = (LuaFunction)m_luaTable["luaSvr_launch"];

            if (luaLaunch != null)
            {
                luaLaunch.call();
            }
        }