Esempio n. 1
0
        public void Init(int id, LuaTable scriptEnv, LuaBehaviour behaviour)
        {
            m_scriptEnv = scriptEnv;
            scriptEnv.Set("self", behaviour);
            int count = behaviour.injections.Length;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    GameObject injection = behaviour.injections[i];
                    if (injection != null)
                    {
                        scriptEnv.Set(injection.name, i);
                    }
                }
                LuaUIManager.PushLuaUI(id, behaviour.injections);
            }
            Action luaAwake = scriptEnv.Get <Action>("Awake");

            scriptEnv.Get("Start", out m_luaStart);
            scriptEnv.Get("Update", out m_luaUpdate);
            scriptEnv.Get("OnDestroy", out m_luaOnDestroy);

            if (luaAwake != null)
            {
                luaAwake();
            }
        }
Esempio n. 2
0
        public int InitLuaBehaviour(MonoBehaviour behaviour)
        {
            LuaUIBase uiBase           = m_luaUIPool.Get();
            int       luaIndex         = m_curLuaUIIndex;
            int       unUsedIndexCount = m_unUsedLuaUIIndexs.size;

            if (unUsedIndexCount > 0)
            {
                luaIndex           = m_unUsedLuaUIIndexs.Pop();
                m_luaUIs[luaIndex] = uiBase;
            }
            else
            {
                m_luaUIs.Add(uiBase);
                m_curLuaUIIndex++;
            }
            LuaBehaviour luaScrpit      = (LuaBehaviour)behaviour;
            LuaTable     scriptEnvTable = CreateNewTableWithLuaFile(luaScrpit.luaFileName);

            uiBase.Init(luaIndex, scriptEnvTable, luaScrpit);
            return(luaIndex);
        }