Пример #1
0
        public static void RootSettingLine(BaseModule module, Action <string> ChangeRootPath)
        {
            bool rootAvailable = module.StateConfigAvailable;

            errorStyle.normal.textColor = Color.red; //TODO: 暂时把初始化放在这里
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("Root:", rootAvailable ? null : module.StateConfigLoadFailedMessage),
                                       rootAvailable ? EditorStyles.label : errorStyle, GUILayout.Width(45));

            string rootPath = EditorGUILayout.DelayedTextField(CommonModule.CommonConfig.Json.PipelineRootPath);

            if (GUILayout.Button("...", miniButtonOptions))
            {
                rootPath = EditorUtility.OpenFolderPanel("打开根目录", CommonModule.CommonConfig.Json.PipelineRootPath, null);
            }
            if (!string.IsNullOrEmpty(rootPath) && rootPath != CommonModule.CommonConfig.Json.PipelineRootPath)
            {
                string result = EBPUtility.OpenPipelineRoot(rootPath);
                if (result != null)
                {
                    bool ensure = true;
                    if (module.IsDirty)
                    {
                        ensure = EditorUtility.DisplayDialog("改变根目录", "更改未保存,是否要放弃更改?", "放弃保存", "返回");
                    }
                    if (ensure)
                    {
                        ChangeRootPath(result);
                    }
                }
                return;
            }
            EditorGUILayout.EndHorizontal();
        }
Пример #2
0
        /// <summary>
        /// //该函数内已经确保了日志目录路径存在(但不确保主日志路径存在)
        /// </summary>
        /// <returns></returns>
        public static bool LoadCommonConfig()
        {
            try
            {
                string[] guids = AssetDatabase.FindAssets(CommonConfigSearchText);
                if (guids.Length == 0)
                {
                    throw new EBPException("未能找到本地公共配置文件! 搜索文本:" + CommonConfigSearchText);
                }
                CommonConfig.Load(AssetDatabase.GUIDToAssetPath(guids[0]));

                if (CommonConfig.IsBatchMode)
                {
                    GenerateLogFolderPath();                                               //确保没有LogPath参数时也存在日志目录路径
                    CommonConfig.CurrentLogFolderPath = EBPUtility.GetArgValue("LogPath"); //只有batchmode才开启自定义日志路径
                }
                else //只有非batchmode才开启根目录检查和自动创建
                {
                    string rootPath = null;
                    if (!string.IsNullOrEmpty(CommonConfig.Json.PipelineRootPath))
                    {
                        rootPath = EBPUtility.OpenPipelineRoot(CommonConfig.Json.PipelineRootPath);
                    }
                    if (rootPath == null)
                    {
                        rootPath = EBPUtility.OpenPipelineRoot();
                    }
                    if (rootPath == null)
                    {
                        return(false);
                    }
                    ChangeRootPath(rootPath);
                }

                return(true);
            }
            catch (Exception e)
            {
                if (CommonConfig.IsBatchMode)
                {
                    throw new EBPException("加载本地公共配置文件时发生错误:" + e.ToString());
                }
                EditorUtility.DisplayDialog("EazyBuildPipeline", "加载本地公共配置文件时发生错误:" + e.Message
                                            + "\n加载路径:" + CommonConfig.JsonPath
                                            + "\n请设置正确的文件名以及形如以下所示的配置文件:\n" + new CommonConfig(), "确定");
                return(false);
            }
        }