/// <summary>
        /// build bundles
        /// </summary>
        /// <param name="param"></param>
        public static void BuildBundles(FBuildParam param)
        {
            string finalSavePath = "";

            finalSavePath = param.savePath;
            //always cooking all bundles
            //if((EGameType) param.gameType == EGameType.EGT_MAX)
            //{
            focusGame = (int)EGameBundle.EGB_ALL;
            //}
            //else
            //{
            //    focusGame = param.gameType;
            //}
            UpdateLuaScripts(false);
            //if we have one update server. skip this
            string url = param.savePath + "/Compressed";

            ResetUrls(url, param.platform);

            //load bundle asset path
            LoadBundleAssetPath();
            UnityEngine.Debug.Log("finalSavePath=" + finalSavePath);

            if (!Directory.Exists(finalSavePath))
            {
                Directory.CreateDirectory(finalSavePath);
            }
            string Folder = finalSavePath + "/tmp";

            string outputPath = Folder;

            if (Directory.Exists(outputPath))
            {
                foreach (string file in Directory.GetFiles(outputPath))
                {
                    File.Delete(file);
                    UnityEngine.Debug.Log("Remove " + file);
                }
            }
            UnityEngine.Debug.Log("outputPath=" + outputPath);

            AssetDatabase.Refresh();


            if (param.type != EBuildType.EBT_BundleQuick)
            {
                UpdateBundleManager();
            }

            //ensure output directory is exist
            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            DoMakeBundle(outputPath, EditorUserBuildSettings.activeBuildTarget);

            //fresh asset data base
            AssetDatabase.Refresh();

            //remove unused asset bundle
            AssetDatabase.RemoveUnusedAssetBundleNames();

            //build bundle manager bundle file
            MakeBMFile(outputPath);

            string[] AllBundles = AssetDatabase.GetAllAssetBundleNames();

            string original_path = finalSavePath + "/Bundle_Basic";

            if (param.type == EBuildType.EBT_Bundle || param.type == EBuildType.EBT_BundleApp)
            {
                if (Directory.Exists(original_path))
                {
                    FileUtil.DeleteFileOrDirectory(original_path);
                }

                finalSavePath = original_path;
            }
            else
            {
                finalSavePath += "/Bundle_Latest";
            }
            UnityEngine.Debug.Log("finalSavePath=" + finalSavePath);

            //ensure path is exist
            if (Directory.Exists(finalSavePath) == false)
            {
                Directory.CreateDirectory(finalSavePath);
            }

            //quick means dlc?
            if (param.type == EBuildType.EBT_BundleQuick)
            {
                BackupLuaBundleFile(finalSavePath);
            }

            foreach (var Bundle in AllBundles)
            {
                string BundlePath = finalSavePath + "/" + Bundle;
                if (!Directory.Exists(Path.GetDirectoryName(BundlePath)))
                {
                    FileSystem.CreatePath(Path.GetDirectoryName(BundlePath));
                }

                if (File.Exists(Folder + "/" + Bundle))
                {
                    FileUtil.ReplaceFile(Folder + "/" + Bundle, BundlePath);
                }
                else
                {
                    UnityEngine.Debug.LogError("Failed cooking bundle:: " + Bundle);
                }
            }
            UnityEngine.Debug.Log("Now compressing bundle:: parameter is :: " + param.ToString());


            //copy bm.data
            if (File.Exists(Folder + "/bm.data"))
            {
                FileUtil.ReplaceFile(Folder + "/bm.data", finalSavePath + "/bm.data");
            }
            if (param.bCompressedBundle)
            {
                //now compress bundle files;
                if (param.type == EBuildType.EBT_Bundle || param.type == EBuildType.EBT_BundleQuick || param.type == EBuildType.EBT_BundleApp)
                {
                    UnityEngine.Debug.Log("Compressing dlc bundle");
                    bool bCopy = false;
                    if (param.type == EBuildType.EBT_BundleApp)
                    {
                        bCopy = true;
                    }

                    //开始压缩
                    if (param.type == EBuildType.EBT_BundleQuick)
                    {
                        SimpleLZMA.CompressFiles(finalSavePath, bCopy, true);
                    }
                    else
                    {
                        SimpleLZMA.CompressFiles(finalSavePath, bCopy);
                    }

                    //now delete the lateset files;
                    // Directory.Delete(finalSavePath, true);
                }
            }
            else
            {
                SimpleLZMA.CompressFile(finalSavePath, true);
            }

            backOldBundleBinary.Clear();
            checkBundleBinary.Clear();
            cookingSetting = null;

            UpdateGameBundlesConfig(param.savePath + "/Compressed");
            AssetDatabase.Refresh();
        }
        /// <summary>
        /// 应用当前Bundle配置打包生成所有的Bundle
        /// </summary>
        public static void Publish(bool bQuick = false)
        {
            BuildTarget   target   = BuildTarget.Android;
            BuildPlatform platform = BuildPlatform.Android;
            string        rootPath = ProjectBuildHelper.GetSaveBundlePath(target, platform);

            //build lua scripts
            DefinedMacro.FGameMacro macro = null;
            TextAsset ass = Resources.Load("DefinedMacro", typeof(TextAsset)) as TextAsset;

            if (ass != null)
            {
                macro = LitJson.JsonMapper.ToObject <DefinedMacro.FGameMacro>(ass.text);
            }

            bool bUseLuajit        = false;
            bool bCompressedBundle = true;

            if (macro != null)
            {
                bUseLuajit        = macro.bUseLuajit;
                bCompressedBundle = macro.bCompressedBundle;
            }
            UpdateLuaScripts(bUseLuajit);

            //if we have one update server. skip this
            string url = rootPath + "/Compressed";

            ResetUrls(url, platform);

            UpdateBundleManager();

            string outpath = rootPath + "/tmp";

            if (Directory.Exists(outpath))
            {
                Directory.Delete(outpath, true);
            }
            Directory.CreateDirectory(outpath);

            AssetDatabase.Refresh();


            UnityEngine.Debug.Log("Build bundle for " + platform.ToString());
            DoMakeBundle(outpath, target);

            MakeBMFile(outpath);

            string[] AllBundles = AssetDatabase.GetAllAssetBundleNames();
            string   tmp        = outpath.Substring(0, outpath.LastIndexOf("/")) + "/Bundle_Latest";

            if (Directory.Exists(tmp))
            {
                if (bCompressedBundle)
                {
                    BackupLuaBundleFile(tmp);
                }
            }
            else
            {
                Directory.CreateDirectory(tmp);
            }

            foreach (var Bundle in AllBundles)
            {
                string BundlePath = tmp + "/" + Bundle;
                if (!Directory.Exists(Path.GetDirectoryName(BundlePath)))
                {
                    FileSystem.CreatePath(Path.GetDirectoryName(BundlePath));
                }
                if (File.Exists(outpath + "/" + Bundle))
                {
                    FileUtil.ReplaceFile(outpath + "/" + Bundle, BundlePath);
                }
                else
                {
                    UnityEngine.Debug.LogError("Failed cooking bundle:: " + Bundle);
                }
            }


            if (bCompressedBundle)
            {
                SimpleLZMA.CompressFiles(outpath, true, false);
            }
            else
            {
                SimpleLZMA.CompressFile(outpath, true);
            }



            checkBundleBinary.Clear();
            backOldBundleBinary.Clear();
            cookingSetting = null;

            if (File.Exists("Assets/Resources/GameBundle.txt"))
            {
                File.Delete("Assets/Resources/GameBundle.txt");
            }

            //create game config
            UpdateGameBundlesConfig(rootPath);
            EditorUtility.DisplayDialog("提示", "打包工作已完成,请检测输出已确定成功打包!", "确定");
        }