static int GetLuaState(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         LuaFramework.LuaManager obj = (LuaFramework.LuaManager)ToLua.CheckObject <LuaFramework.LuaManager>(L, 1);
         LuaInterface.LuaState   o   = obj.GetLuaState();
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 2
0
        public void Init(LuaTable tb)
        {
            LuaManager luaMgr = AppFacade.Instance.GetManager <LuaManager>(ManagerName.Lua);

            mLuaState = luaMgr.GetLuaState();
            if (mLuaState == null)
            {
                return;
            }

            if (tb == null)
            {
                mLuaTable = mLuaState.GetTable(name);
            }
            else
            {
                mLuaTable = tb;
            }
            if (mLuaTable == null)
            {
                Debug.LogWarning("mLuaTable is null:" + name);
                return;
            }
            mLuaTable["gameObject"]    = gameObject;
            mLuaTable["transform"]     = transform;
            mLuaTable["lua_behaviour"] = this;

            LuaFunction awakeFunc = mLuaTable.GetLuaFunction("Awake") as LuaFunction;

            if (awakeFunc != null)
            {
                awakeFunc.BeginPCall();
                awakeFunc.Push(mLuaTable);
                awakeFunc.PCall();
                awakeFunc.EndPCall();

                awakeFunc.Dispose();
                awakeFunc = null;
            }

            mUpdateFunc      = mLuaTable.GetLuaFunction("Update") as LuaFunction;
            mFixedUpdateFunc = mLuaTable.GetLuaFunction("FixedUpdate") as LuaFunction;
            mLateUpdateFunc  = mLuaTable.GetLuaFunction("LateUpdate") as LuaFunction;
        }