Exemplo n.º 1
0
        public void Init(LuaTable tb, GObject ui)
        {
            mLuaState = MyLuaClient.GetMainState();
            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["ui"]            = ui;
            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;
        }
Exemplo n.º 2
0
 // Use this for initialization
 void Awake()
 {
     loader       = new LuaLoader();
     mMyLuaClient = gameObject.AddComponent <MyLuaClient>();
     lua          = MyLuaClient.GetMainState();
 }