public static bool BuildGame(GameBuilderParameter para) { Debug.Log("Build Game Start and Para is:" + para); if (!para.BuildVersion.CheckConstraint()) { Debug.LogError("BuildVersion not pass constraint! version:" + para.BuildVersion.GetVersionString()); return(false); } try { if (para.BuildTarget == BuildTarget.iOS) { para.UseMono2X = false; Debug.Log("ios platform always use IL2ccpp. is not will compiler error"); } // 处理热更url if (!HandleHotFix(para)) { return(false); } Debug.Log("Clear " + Application.streamingAssetsPath); FileUtils.ClearDirectoryReadOnly(Application.streamingAssetsPath); FileUtils.ClearDirectory(Application.streamingAssetsPath); SetupSetting(para); // build lua bundle Debug.Log("Start MarkBundlesNames "); ToLuaMenu.MarkBundlesNames(); Debug.Log("End MarkBundlesNames "); if (para.ApplyAllRule) { Debug.Log("Start ApplyAllRule "); AssetBundleRuleUtils.ApplyAll(null, true); Debug.Log("ApplyAllRule finish "); } string sourcePath = Path.Combine(Utility.AssetBundlesOutputPath, Utility.GetPlatformName()); if (!para.IncreativeBuildAssetBundles) { Debug.Log("Clear Assetbundle dir:" + sourcePath); FileUtils.ClearDirectoryReadOnly(sourcePath); FileUtils.ClearDirectory(sourcePath); Debug.Log("finish Clear Assetbundle dir:"); } Debug.Log("BuildAssetBundles to " + sourcePath); BuildScript.BuildAssetBundles(null, para.BundleCompress ? ToLuaMenu.GetBuildAssetBundleOptions(): BuildAssetBundleOptions.None); Debug.Log("BuildAssetBundles finish "); Debug.Log("Start CopyDirectory to Streaming"); FileUtils.CopyDirectory(sourcePath, VersionConst.StreamingVersionPath); Debug.Log("Finish CopyDirectory to Streaming"); // 这个放在下面,不然会被前面的删除掉 if (para.CopyFmod) { // -音效引擎相关代码,放在打包资源之后因为会清理打包资源-// Debug.Log("CopyToStreamingAssets---------------------------------------"); //EventManager.DoCopyToStreamingAssets(); Debug.Log("MasterBankName---------------------------------------"); } Debug.Log("GenHotFixFileListAndCheckConflict"); AssetBundleRuleUtils.GenHotFixFileListAndCheckConflict(); bool bOk = true; if (para.BuildMode == BuildMode.Patch || para.BuildMode == BuildMode.All) { Debug.Log("开始生成补丁"); VersionPatchBuilder patchBuilder = new VersionPatchBuilder(para.BuildTarget, para.BuildVersion, para.BuildNumber); if (!patchBuilder.Build()) { bOk = false; } Debug.Log("结束生成补丁"); } // 如果要求生成补丁,但补丁失败,则包也 if (bOk && (para.BuildMode == BuildMode.Package || para.BuildMode == BuildMode.All)) { Debug.Log("开始写入发布时版本信息:" + VersionConst.ReleasedVersionPath); // 写入发布版本信息 SaveReleasedVersionFile(para.BuildVersion, VersionConst.ReleasedVersionPath); Debug.Log("结束写入发布时版本信息"); Debug.Log("开始生成安装包"); string[] levels = BuilderEditorUtils.GetBuildScenes(); var error = BuildPipeline.BuildPlayer(levels , para.OutputPath , para.BuildTarget , para.BuildOptions); if (!string.IsNullOrEmpty(error)) { Debug.LogError("Build failed: " + error); bOk = false; } Debug.Log("结束生成安装包"); } return(bOk); } catch (Exception e) { Debug.LogError("error BuildGame stderror exception: " + e.Message); return(false); } }