private void RunCurrentSetp() { try { switch (currentStep) { case Step.Start: scrollPosition.x = 0; startTime = EditorApplication.timeSinceStartup; CommonModule.GenerateLogFolderPath(); currentStep = Step.SVNUpdate; break; case Step.SVNUpdate: if (G.Module.SVNUpdateRunner.IsPartOfPipeline) { G.Module.SVNUpdateRunner.Run(); } currentStep = Step.Prepare; break; case Step.Prepare: var state4_pre = G.Module.PlayerBuilderModule.ModuleStateConfig; if (state4_pre.Json.IsPartOfPipeline) { state4_pre.Json.ResourceVersion = G.Module.BundleManagerModule.ModuleStateConfig.Json.ResourceVersion; state4_pre.Json.ClientVersion = G.Module.PackageManagerModule.ModuleStateConfig.Json.ClientVersion; G.Module.PlayerBuilderRunner.Prepare(); } currentStep = Step.PreprocessAssets; break; case Step.PreprocessAssets: var state = G.Module.AssetPreprocessorModule.ModuleStateConfig; //TODO:每个Setp中都是重复的内容,可优化 if (state.Json.IsPartOfPipeline) { G.Module.AssetPreprocessorRunner.Run(true); } else if (!string.IsNullOrEmpty(state.Json.CurrentUserConfigName)) { state.Load(); //TODO:为什么要load? state.Json.IsPartOfPipeline = false; state.Save(); } currentStep = Step.BuildBundles; break; case Step.BuildBundles: var state2 = G.Module.BundleManagerModule.ModuleStateConfig; if (state2.Json.IsPartOfPipeline) { G.Module.BundleManagerRunner.Run(true); } else if (!string.IsNullOrEmpty(state2.Json.CurrentUserConfigName)) { state2.Load(); state2.Json.IsPartOfPipeline = false; state2.Save(); } currentStep = Step.BuildPackages; break; case Step.BuildPackages: var state3 = G.Module.PackageManagerModule.ModuleStateConfig; if (state3.Json.IsPartOfPipeline) { state3.Json.ResourceVersion = G.Module.BundleManagerModule.ModuleStateConfig.Json.ResourceVersion; G.Module.PackageManagerRunner.Run(true); } else if (!string.IsNullOrEmpty(state3.Json.CurrentUserConfigName)) { state3.Load(); state3.Json.IsPartOfPipeline = false; state3.Save(); } currentStep = Step.BuildPlayer; break; case Step.BuildPlayer: var state4 = G.Module.PlayerBuilderModule.ModuleStateConfig; if (state4.Json.IsPartOfPipeline) { G.Module.PlayerBuilderRunner.Run(true); } else if (!string.IsNullOrEmpty(state4.Json.CurrentUserConfigName)) { state4.Load(); state4.Json.IsPartOfPipeline = false; state4.Save(); } currentStep = Step.Finish; break; case Step.Finish: TimeSpan endTime = TimeSpan.FromSeconds(EditorApplication.timeSinceStartup - startTime); G.Module.DisplayDialog(string.Format("管线运行成功!用时:{0}时 {1}分 {2}秒", endTime.Hours, endTime.Minutes, endTime.Seconds)); currentStep = Step.None; EditorApplication.update -= UpdateForRun; break; } } catch (Exception e) { TimeSpan endTime = TimeSpan.FromSeconds(EditorApplication.timeSinceStartup - startTime); BaseModule currentModule = null; switch (currentStep) { case Step.SVNUpdate: currentModule = G.Module.SVNUpdateModule; break; case Step.PreprocessAssets: currentModule = G.Module.AssetPreprocessorModule; break; case Step.BuildBundles: currentModule = G.Module.BundleManagerModule; break; case Step.BuildPackages: currentModule = G.Module.PackageManagerModule; break; case Step.BuildPlayer: currentModule = G.Module.PlayerBuilderModule; break; default: break; } string timeInfo = string.Format("用时:{0}时 {1}分 {2}秒\n", endTime.Hours, endTime.Minutes, endTime.Seconds); if (currentModule == null) { G.Module.DisplayDialog("管线运行时发生错误!" + timeInfo + "错误信息:" + e.Message); } else { currentModule.DisplayRunError(timeInfo); } currentStep = Step.None; EditorApplication.update -= UpdateForRun; } finally { G.g.MainWindow.Repaint(); } }