private void ClickedApply()
        {
            try
            {
                CommonModule.ClearLogFolderPath();
                G.Runner.Check();
            }
            catch (EBPCheckFailedException e)
            {
                G.Module.DisplayDialog(e.Message);
                return;
            }
            bool ensure = G.Module.DisplayDialog("确定应用当前配置?应用过程不可中断。", "确定", "取消");

            if (ensure)
            {
                try
                {
                    CommonModule.GenerateLogFolderPath();
                    G.Runner.Run();
                }
                catch
                {
                    G.Module.DisplayRunError();
                    return;
                }

                string s = "转换完成!\n";
                if (G.Runner.process.ExitCode != 0)
                {
                    s = string.Format("操作中断!执行第{0}步时出错:{1}\n", G.Runner.currentShellIndex + 1, G.Runner.errorMessage);
                }
                s += string.Format("\n第一步(拷贝文件):\nPreStoredAssets中符合标签的文件共有{0}个,跳过{1}个,成功拷贝{2}个。\n",
                                   G.Runner.totalCountList[0], G.Runner.skipCountList[0], G.Runner.successCountList[0]);
                if (G.Runner.currentShellIndex >= 1)
                {
                    s += string.Format("\n第二步(修改meta):\n共有{0}个meta文件,跳过{1}个,成功修改{2}个。\n",
                                       G.Runner.totalCountList[1], G.Runner.skipCountList[1], G.Runner.successCountList[1]);
                }
                else
                {
                    s += "\n第二步未执行";
                }

                if (G.Module.DisplayDialog(s, "查看日志文件", "关闭"))
                {
                    foreach (string logFilePath in G.Runner.LogFilePathList)
                    {
                        if (!string.IsNullOrEmpty(logFilePath))
                        {
                            EditorUtility.OpenWithDefaultApp(logFilePath);
                        }
                    }
                }
            }
        }
        private void ClickedApply()
        {
            try
            {
                CommonModule.ClearLogFolderPath();
                G.Runner.Check();
            }
            catch (EBPCheckFailedException e)
            {
                G.Module.DisplayDialog(e.Message);
                return;
            }
            bool ensure = G.Module.DisplayDialog("确定应用当前配置?应用过程不可中断。", "确定", "取消");

            if (ensure)
            {
                try
                {
                    CommonModule.GenerateLogFolderPath();
                    G.Runner.Run();
                }
                catch
                {
                    G.Module.DisplayRunError();
                    return;
                }

                string s = "转换完成!\n";
                s += string.Format("\n第一步(资产替换):\nPreStoredAssets中符合标签的文件共有{0}个,跳过{1}个,成功拷贝{2}个。\n",
                                   G.Runner.totalCountList[0], G.Runner.skipCountList[0], G.Runner.successCountList[0]);

                s += string.Format("\n第二步(修改AssetImporter设置):\n共找到{0}个Importer,跳过{1}个,成功修改{2}个。\n",
                                   G.Runner.totalCountList[1], G.Runner.skipCountList[1], G.Runner.successCountList[1]);

                if (G.Module.DisplayDialog(s, "查看日志文件", "关闭"))
                {
                    foreach (string logFilePath in G.Runner.LogFilePathList)
                    {
                        if (!string.IsNullOrEmpty(logFilePath))
                        {
                            EditorUtility.OpenWithDefaultApp(logFilePath);
                        }
                    }
                }
            }
        }
        private void ClickedApply()
        {
            G.Module.UserConfig.Json.Packages = GetPackageMap(); //从配置现场覆盖当前map
            try
            {
                CommonModule.ClearLogFolderPath();
                G.Runner.Check();
            }
            catch (EBPCheckFailedException e)
            {
                G.Module.DisplayDialog(e.Message);
                return;
            }
            if (!CheckAllPackageItem())
            {
                return;
            }

            bool ensure = G.Module.DisplayDialog("确定应用当前配置?", "确定", "取消");

            if (ensure)
            {
                try
                {
                    G.Module.DisplayProgressBar("Build Packages", "Starting...", 0);
                    double startTime = EditorApplication.timeSinceStartup;

                    CommonModule.GenerateLogFolderPath();
                    G.Runner.Run();

                    TimeSpan time = TimeSpan.FromSeconds(EditorApplication.timeSinceStartup - startTime);
                    if (G.Module.DisplayDialog("打包完成!用时:" + string.Format("{0}时 {1}分 {2}秒", time.Hours, time.Minutes, time.Seconds),
                                               "显示文件", "关闭"))
                    {
                        string firstPackagePath = Path.Combine(G.Module.ModuleConfig.WorkPath, EBPUtility.GetTagStr(G.Module.ModuleStateConfig.Json.CurrentTag));
                        EditorUtility.RevealInFinder(firstPackagePath);
                    }
                }
                catch
                {
                    G.Module.DisplayRunError();
                }
            }
        }
Example #4
0
        private void ClickedApply()
        {
            G.Module.ModuleStateConfig.Json.CurrentUserConfigName = Path.GetFileName(AssetBundleManagement2.AssetBundleModel.BuildMapPath) + ".json"; //TODO: 覆盖当前map文件名,BundleMaster的特殊处理
            G.Module.UserConfig.Json = G.g.mainTab.GetBuildMap_extension().ToList();                                                                  //从配置现场覆盖当前map
            try
            {
                CommonModule.ClearLogFolderPath();
                G.Runner.Check();
            }
            catch (EBPCheckFailedException e)
            {
                G.Module.DisplayDialog(e.Message);
                return;
            }
            //确认信息
            BuildTarget target          = (BuildTarget)Enum.Parse(typeof(BuildTarget), G.Module.ModuleStateConfig.Json.CurrentTag[0], true);
            int         optionsValue    = G.Module.ModuleStateConfig.Json.CurrentBuildAssetBundleOptionsValue;
            int         resourceVersion = G.Module.ModuleStateConfig.Json.ResourceVersion;
            string      tagPath         = Path.Combine(G.Module.ModuleConfig.WorkPath, EBPUtility.GetTagStr(G.Module.ModuleStateConfig.Json.CurrentTag));

            bool ensure = G.Module.DisplayDialog(string.Format("确定应用当前配置?\n\n" +
                                                               "目标平台: {0}\n 输出路径: {1} \n Resources Version: {2} \n 参数: {3}",
                                                               target, tagPath, resourceVersion, optionsValue), "确定", "取消");

            //开始应用
            if (ensure)
            {
                try
                {
                    CommonModule.GenerateLogFolderPath();
                    G.Runner.Run();
                    G.Module.DisplayDialog("创建AssetBundles成功!");
                }
                catch
                {
                    G.Module.DisplayRunError();
                }
            }
        }
        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();
            }
        }