コード例 #1
0
        private LuaEnv luaEnv;      // 全局唯一的lua虚拟机

        void Awake()
        {
            luaEnv    = LuaMgr.luaEnv;
            scriptEnv = luaEnv.NewTable();

            LuaTable meta = luaEnv.NewTable(); // 元表

            meta.Set("__index", luaEnv.Global);
            scriptEnv.SetMetaTable(meta);
            meta.Dispose();

            string prefabName = name;

            if (prefabName.Contains("(Clone)"))
            {
                prefabName = prefabName.Split('(')[0];
            }
            prefabName = prefabName.Replace("pan_", "");

            luaAwake     = scriptEnv.GetInPath <LuaViewBehaviour.delLuaAwake>(prefabName + ".awake");
            luaStart     = scriptEnv.GetInPath <LuaViewBehaviour.delLuaStart>(prefabName + ".start");
            luaUpdate    = scriptEnv.GetInPath <LuaViewBehaviour.delLuaUpdate>(prefabName + ".update");
            luaOnDestroy = scriptEnv.GetInPath <LuaViewBehaviour.delLuaOnDestroy>(prefabName + ".ondestroy");

            scriptEnv.Set("self", this);

            if (luaAwake != null)
            {
                luaAwake(gameObject);
            }
        }
コード例 #2
0
        void OnDestroy()
        {
            if (luaOnDestroy != null)
            {
                luaOnDestroy();
            }

            luaOnDestroy = null;
            luaUpdate    = null;
            luaStart     = null;
            luaAwake     = null;
        }