Esempio n. 1
0
    public void Initialize()
    {
        Lua = new LuaEnv();
        Lua.AddBuildin("rapidjson", XLua.LuaDLL.Lua.LoadRapidJson);



        if (LuaConst.DebugMode == true)
        {
            string path = Application.dataPath + "/XLua/EasyXLua/ToBuild/lua/";
            GetAllFiles(new DirectoryInfo(path));
        }
        else
        {
            if (LuaConst.LuaBundleMode)
            {
                string      uri    = LuaConst.DataPath + "Lua.medsci";
                byte[]      stream = File.ReadAllBytes(uri);
                AssetBundle bundle = AssetBundle.LoadFromMemory(stream);
                TextAsset[] TA     = bundle.LoadAllAssets <TextAsset>();
                foreach (TextAsset t in TA)
                {
                    string luaDecrypt = LuaConst.Decrypt(t.text, "12345678", "56781234");
                    LuaDict.Add(t.name, System.Text.Encoding.UTF8.GetBytes(luaDecrypt));
                }
            }
            else
            {
                string path = LuaConst.DataPath + "/lua/";
                GetAllFiles(new DirectoryInfo(path));
            }
        }
        XLua.LuaEnv.CustomLoader CL = new XLua.LuaEnv.CustomLoader(GetLuaFiles);
        Lua.AddLoader(CL);
    }