Exemplo n.º 1
0
 protected void StartLoader()
 {
     loader = gameObject.AddComponent <LuaLoader>();
     if (LuaFileUtils.Instance.beZip)
     {
         loader.AddBundle("lua/tolua.ab");
         loader.AddBundle("lua/lua.ab");
     }
 }
Exemplo n.º 2
0
    public void Init()
    {
        _loader = new LuaLoader();
        _lua    = new LuaState();
        OpenLibs();
        lua.LuaSetTop(0);
        LuaBinder.Bind(_lua);
        DelegateFactory.Init();
        LuaCoroutine.Register(_lua, this);

        // Lua读取路径
        _loader.beZip = GameMain.Inst.ResourceMode != 0;

        // 如果是打包模式,读AB,否则读Lua目录
        if (_loader.beZip)
        {
            if (IsEncode)
            {
#if UNITY_ANDROID
                if (IntPtr.Size == 8) //64位
                {
                    cpuTypeStr = "64_";
                }
#elif UNITY_IOS
                cpuTypeStr = "64_";
#endif
            }
            _loader.AddBundle("lua_" + cpuTypeStr + "logic");
            _loader.AddBundle("lua_" + cpuTypeStr + "module");
            _loader.AddBundle("lua_" + cpuTypeStr + "tolua");
            _loader.AddBundle("lua_" + cpuTypeStr + "ui");
            _loader.AddBundle("lua_" + cpuTypeStr + "utils");
        }
        else
        {
            _lua.AddSearchPath(LuaConst.luaDir);
            _lua.AddSearchPath(LuaConst.luaDir + "/ToLua");
        }

        //启动LuaVM
        _lua.Start();

        // Lua计时
        gameObject.AddComponent <LuaLooper>().luaState = _lua;

        // 添加lua之间的引用关系
        DoFile("logic/Main");
    }
Exemplo n.º 3
0
 /// <summary>
 /// 初始化LuaBundle
 /// </summary>
 void InitLuaBundle()
 {
     if (loader.beZip)
     {
         loader.AddBundle();
     }
 }
Exemplo n.º 4
0
    /// <summary>
    /// 初始化LuaBundle
    /// </summary>
    void InitLuaBundle()
    {
        if (loader.beZip)
        {
            loader.AddBundle("lua/lua.unity3d");
            loader.AddBundle("lua/lua_system.unity3d");
            loader.AddBundle("lua/lua_system_reflection.unity3d");
            loader.AddBundle("lua/lua_system_injection.unity3d");
            loader.AddBundle("lua/lua_unityengine.unity3d");
            loader.AddBundle("lua/lua_misc.unity3d");

            loader.AddBundle("lua/lua_protobuf.unity3d");
            loader.AddBundle("lua/lua_protos.unity3d");
            loader.AddBundle("lua/lua_tools_events.unity3d");
            loader.AddBundle("lua/lua_windows.unity3d");
        }
    }
Exemplo n.º 5
0
    public void Init()
    {
        _loader = new LuaLoader();
        _lua    = new LuaState();
        OpenLibs();

        LuaBinder.Bind(_lua);
        DelegateFactory.Register();
        LuaCoroutine.Register(_lua, this);

        // Lua读取路径
        LuaFileUtils.Instance.beZip = AppConst.resourceMode != 0;

        // 如果是打包模式,读AB,否则读Lua目录
        if (LuaFileUtils.Instance.beZip)
        {
            _loader.AddBundle("lua_ui");
            _loader.AddBundle("lua_logic");
            _loader.AddBundle("lua_protobuf");
            _loader.AddBundle("lua_protocols");
            _loader.AddBundle("lua_tolua");
            _loader.AddBundle("lua_fight");
            _loader.AddBundle("lua_character");
            _loader.AddBundle("lua_utils");
            _loader.AddBundle("lua_skill");
            _loader.AddBundle("lua_cache");
        }
        else
        {
            _lua.AddSearchPath(LuaConst.luaDir);
        }

        //启动LuaVM
        _lua.Start();

        // Lua计时
        gameObject.AddComponent <LuaLooper>().luaState = _lua;

        // 添加lua之间的引用关系
        DoFile("logic/Main");
    }
Exemplo n.º 6
0
 /// <summary>
 /// 初始化LuaBundle
 /// </summary>
 void InitLuaBundle()
 {
     if (loader.beZip)
     {
         DirectoryInfo dir          = new DirectoryInfo(Util.DataPath + "/lua");
         FileInfo[]    unity3dFiles = dir.GetFiles("*.unity3d");
         for (int i = 0; i < unity3dFiles.Length; i++)
         {
             FileInfo fi = unity3dFiles[i];
             loader.AddBundle("lua/" + fi.Name);
         }
     }
 }
Exemplo n.º 7
0
    /// <summary>
    /// 初始化LuaBundle
    /// </summary>
    void InitLuaBundle()
    {
        string streamDir = AppConst.DataPath + "lua";

        //Debug.Log("文件路径" + streamDir);
        string[] files = Directory.GetFiles(streamDir, "*.unity3d", SearchOption.AllDirectories);
        //Debug.Log("得到的文件长度" + files.Length);
        for (int i = 0; i < files.Length; i++)
        {
            files[i] = files[i].Replace("\\", "/");
            //Debug.Log("文件名字" + files[i]);
            string [] file = files[i].Split('/');
            //Debug.Log("文件长度" + file.Length);
            loader.AddBundle("lua/" + file[file.Length - 1]);
        }
    }
Exemplo n.º 8
0
        /// <summary>
        /// 初始化LuaBundle
        /// </summary>
        void InitLuaBundle()
        {
            Util.LogError("InitLuaBundle");
            if (loader.beZip)
            {
                //查找所有的unity3d
                string[] filesNames = System.IO.Directory.GetFiles(Util.DataPath + "lua/", "*.unity3d");
                foreach (string filename in filesNames)
                {
                    string luaName = filename.Replace('\\', '/');
                    luaName = luaName.Substring(luaName.LastIndexOf('/') + 1);
                    loader.AddBundle("lua/" + luaName);
                }

                //loader.AddBundle("lua/lua.unity3d");
                //loader.AddBundle("lua/lua_logic_base.unity3d");
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// 初始化LuaBundle
 /// </summary>
 private void InitLuaBundle()
 {
     if (m_LuaLoader.beZip)
     {
         List <string> filesList     = new List <string>();
         string[]      names         = Directory.GetFiles(FrameworkUtil.DataPath + FrameworkDefine.LUA_DIR);
         string        addbundelname = "";
         foreach (string filename in names)
         {
             string name = Path.GetFileName(filename.Replace('\\', '/'));
             if (name.EndsWith(FrameworkDefine.EXT_NAME))
             {
                 addbundelname = FrameworkDefine.LUA_DIR + "/" + name;
                 filesList.Add(addbundelname);
                 m_LuaLoader.AddBundle(addbundelname);
             }
         }
     }
 }
Exemplo n.º 10
0
    /// <summary>
    /// 初始化LuaBundle
    /// </summary>
    void InitLuaBundle()
    {
        if (loader.beZip)
        {
            loader.AddBundle("lua/lua.unity3d");
            loader.AddBundle("lua/lua_system.unity3d");
            loader.AddBundle("lua/lua_system_reflection.unity3d");
            loader.AddBundle("lua/lua_unityengine.unity3d");
            loader.AddBundle("lua/lua_common.unity3d");
            loader.AddBundle("lua/lua_cs-common.unity3d");
            loader.AddBundle("lua/lua_misc.unity3d");

            loader.AddBundle("lua/lua_protobuf.unity3d");
            loader.AddBundle("lua/lua_3rd_cjson.unity3d");
            loader.AddBundle("lua/lua_3rd_luabitop.unity3d");
            loader.AddBundle("lua/lua_3rd_pbc.unity3d");
            loader.AddBundle("lua/lua_3rd_pblua.unity3d");
            loader.AddBundle("lua/lua_3rd_sproto.unity3d");

            //for game
            loader.AddBundle("lua/lua_modules_ccmj_control.unity3d");
            loader.AddBundle("lua/lua_modules_ccmj_view.unity3d");
            loader.AddBundle("lua/lua_modules_ddz_controller.unity3d");
            loader.AddBundle("lua/lua_modules_ddz_view.unity3d");
            loader.AddBundle("lua/lua_modules_main_control.unity3d");
            loader.AddBundle("lua/lua_modules_main_view.unity3d");
            loader.AddBundle("lua/lua_modules_main_view_item.unity3d");
        }
    }
Exemplo n.º 11
0
 /// <summary>
 /// 初始化LuaBundle
 /// </summary>
 void InitLuaBundle()
 {
     if (loader.beZip)
     {
         loader.AddBundle("lua/lua.unity3d");
         loader.AddBundle("lua/lua_cjson.unity3d");
         loader.AddBundle("lua/lua_controller.unity3d");
         loader.AddBundle("lua/lua_lpeg.unity3d");
         loader.AddBundle("lua/lua_misc.unity3d");
         loader.AddBundle("lua/lua_protobuf.unity3d");
         loader.AddBundle("lua/lua_socket.unity3d");
         loader.AddBundle("lua/lua_system.unity3d");
         loader.AddBundle("lua/lua_system_reflection.unity3d");
         loader.AddBundle("lua/lua_unityengine.unity3d");
         loader.AddBundle("lua/lua_view.unity3d");
     }
 }
Exemplo n.º 12
0
    /// <summary>
    /// 初始化LuaBundle
    /// </summary>
    void InitLuaBundle()
    {
        if (loader.beZip)
        {
            loader.AddBundle("lua/lua.unity3d");
            loader.AddBundle("lua/lua_math.unity3d");
            loader.AddBundle("lua/lua_system.unity3d");
            loader.AddBundle("lua/lua_system_reflection.unity3d");
            loader.AddBundle("lua/lua_unityengine.unity3d");
            loader.AddBundle("lua/lua_common.unity3d");
            loader.AddBundle("lua/lua_logic.unity3d");
            loader.AddBundle("lua/lua_view.unity3d");
            loader.AddBundle("lua/lua_controller.unity3d");
            loader.AddBundle("lua/lua_misc.unity3d");

            loader.AddBundle("lua/lua_protobuf.unity3d");
            loader.AddBundle("lua/lua_3rd_cjson.unity3d");
            loader.AddBundle("lua/lua_3rd_luabitop.unity3d");
            loader.AddBundle("lua/lua_3rd_pbc.unity3d");
            loader.AddBundle("lua/lua_3rd_pblua.unity3d");
            loader.AddBundle("lua/lua_3rd_sproto.unity3d");
        }
    }