Ejemplo n.º 1
0
        private void DoInit()
        {
            Env = new LuaEnv();
            ScriptLoader scriptLoader;

#if UNITY_EDITOR
            scriptLoader = new FileScriptLoader();
#else
#endif
            Env.AddLoader(scriptLoader.LoadScript);

#if DEBUG
            Global.Set("isDebug", true);
#endif
            Env.AddBuildin("rapidjson", XLua.LuaDLL.Lua.LoadRapidJson);
            Global.Set("isUsingRapidjson", true);

            Env.AddBuildin("pb", XLua.LuaDLL.Lua.LoadLuaProfobuf);

            OOPTable         = RequireAndGetLocalTable(LUA_OOP_PATH);
            usingFunc        = OOPTable.Get <Func <string, LuaTable> >("using");
            instanceFunc     = OOPTable.Get <Func <string, LuaTable> >("instance");
            instanceWithFunc = OOPTable.Get <LuaFunction>("instancewith");

            Require(LUA_INIT_PATH);
            GameTable        = Global.Get <LuaTable>(LUA_GLOBAL_NAME);
            updateAction     = GameTable.Get <Action <float, float> >(LuaUtility.UPDATE_FUNCTION_NAME);
            lateUpdateAction = GameTable.Get <Action>(LuaUtility.LATEUPDATE_FUNCTION_NAME);

            Action initAction = GameTable.Get <Action>(LuaUtility.INIT_FUNCTION_NAME);
            initAction?.Invoke();
        }
Ejemplo n.º 2
0
        public void Shuntdown()
        {
            if (envBehaviour != null)
            {
                UnityObject.Destroy(envBehaviour.gameObject);
                envBehaviour = null;
            }

            if (IsValid)
            {
                if (localLanguage != null)
                {
                    localLanguage.Dispose();
                }

                LuaFunction destroyFunc = GameTable.Get <LuaFunction>(LuaUtility.DESTROY_FUNCTION_NAME);
                destroyFunc.Action();
                destroyFunc.Dispose();

                instanceWithFunc.Dispose();
                OOPTable.Dispose();
                GameTable.Dispose();
            }

            localLanguage = null;

            updateAction     = null;
            lateUpdateAction = null;
            usingFunc        = null;
            instanceFunc     = null;
            instanceWithFunc = null;
            GameTable        = null;
            OOPTable         = null;

            if (IsValid)
            {
                Env.FullGc();
                Env.Dispose();
            }
            Env     = null;
            manager = null;
        }
Ejemplo n.º 3
0
        public void DoStart()
        {
            Action startAction = GameTable.Get <Action>(LuaUtility.START_FUNCTION_NAME);

            startAction?.Invoke();
        }