예제 #1
0
파일: LuaBehaviour.cs 프로젝트: mengtest/u1
        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;
        }
예제 #2
0
파일: LuaManager.cs 프로젝트: mengtest/u1
 // Use this for initialization
 void Awake()
 {
     loader       = new LuaLoader();
     mMyLuaClient = gameObject.AddComponent <MyLuaClient>();
     lua          = MyLuaClient.GetMainState();
 }