//        这里不要chache了 实时读取
//        private static DefaultControlPropertyConfig ConfigControlProperty {  get; set; }
//        private static DefaultEditorPropertyConfig ConfigEditorProperty {  get; set; }
//        private static CustomControlPropertyConfig ConfigCustomControlProperty {  get; set; }
//        private static CustomEditorPropertyConfig ConfigCustomEditorProperty {  get; set; }
//        private static CodeGenConfig ConfigCodeGen {  get; set; }


        public static CodeGenConfig GetCodeGenConfig(bool reload = false)
        {
//            if (ConfigCodeGen == null || reload)
//            {
//                ConfigCodeGen = ConfigContainerFactory.GetInstance().LoadConfig<CodeGenConfig>(CodeGenFilePath);
//            }
//
//            return ConfigCodeGen;
            return(ConfigContainerFactory.GetInstance(DataContainerType.EDITOR_UNITY_JSON).LoadConfig <CodeGenConfig>(CodeGenFilePath));
        }
Exemple #2
0
        /// <summary>
        /// 保存配置(逻辑)
        /// </summary>
        protected virtual void SaveConfig()
        {
            //批量调用校验逻辑
            if (!VerfiyExportData())
            {
                return;
            }
            //批量调用校验逻辑


            var temp = new List <T>();

            //处理删除逻辑
            for (int i = 0; i < deleteList.Count; i++)
            {
                foreach (var VARIABLE in Data.config_current.ConfigList)
                {
                    if (VARIABLE.GetHashCode() == deleteList[i])
                    {
                        temp.Add(VARIABLE);
                        break;
                    }
                }
            }

            for (int i = 0; i < temp.Count; i++)
            {
                Data.config_current.ConfigList.Remove(temp[i]);
            }

            deleteList.Clear();
            Data.SyncData();
            //处理删除逻辑


            //处理路径关系

            if (GetCodeGenInfo() == null)
            {
                ShowNotification(new GUIContent(Language.CantReadOutputPath));
                return;
            }

            var code_info = GetCodeGenInfo();//请注意这里 一定要先获取代码生成信息

            if (ConfigContainerFactory.GetInstance(code_info.ContainerType).SaveToDisk(code_info.InOutPath, Data.config_current))
            {
                AssetDatabase.Refresh();
                ShowNotification(new GUIContent(Language.Success));
            }
            else
            {
                ShowNotification(new GUIContent(Language.SaveFailed));
            }
        }
        public static CustomControlPropertyConfig GetCustomControlPropertyConfig(bool reload = false)
        {
//            if (ConfigCustomControlProperty == null || reload)
//            {
//                ConfigCustomControlProperty = ConfigContainerFactory.GetInstance().LoadConfig<CustomControlPropertyConfig>(CustomControlPropertyConfigPath);
//            }
//
//            return ConfigCustomControlProperty;
            return(ConfigContainerFactory.GetInstance(DataContainerType.EDITOR_UNITY_JSON)
                   .LoadConfig <CustomControlPropertyConfig>(CustomControlPropertyConfigPath));
        }
        public static DefaultEditorPropertyConfig GetDefaultEditorPropertyConfig(bool reload = false)
        {
//            if (ConfigEditorProperty == null || reload)
//            {
//                ConfigEditorProperty = ConfigContainerFactory.GetInstance()
//                    .LoadConfig<DefaultEditorPropertyConfig>(DefaultEditorPropertyConfigPath);
//            }
//
//            return ConfigEditorProperty;
            return(ConfigContainerFactory.GetInstance(DataContainerType.EDITOR_UNITY_JSON)
                   .LoadConfig <DefaultEditorPropertyConfig>(DefaultEditorPropertyConfigPath));
        }
        public static DefaultControlPropertyConfig GetDefaultControlPropertyConfig(bool reload = false)
        {
//            if (ConfigControlProperty == null || reload)
//            {
//                ConfigControlProperty = ConfigContainerFactory.GetInstance()
//                    .LoadConfig<DefaultControlPropertyConfig>(DefaultControlPropertyConfigPath);
//            }
//
//            return ConfigControlProperty;
            return(ConfigContainerFactory.GetInstance()
                   .LoadConfig <DefaultControlPropertyConfig>(DefaultControlPropertyConfigPath));
        }
        public static CustomEditorPropertyConfig GetCustomEditorPropertyConfig(bool reload = false)
        {
//            if (ConfigCustomEditorProperty == null || reload)
//            {
//                ConfigCustomEditorProperty = ConfigContainerFactory.GetInstance()
//                    .LoadConfig<CustomEditorPropertyConfig>(CustomEditorPropertyConfigPath);
//            }
//
//            return ConfigCustomEditorProperty;
            return(ConfigContainerFactory.GetInstance()
                   .LoadConfig <CustomEditorPropertyConfig>(CustomEditorPropertyConfigPath));
        }
Exemple #7
0
        /// <summary>
        /// Reload 但不包括 SetConfigType 与 Initialize
        /// </summary>
        protected virtual void Reload()
        {
            AssetDatabase.Refresh();
            FieldsOrder = new Dictionary <string, bool>();

            var code_info = GetCodeGenInfo();//先获取加载配置信息 不然会debug很久的

            Data.config_current = ConfigContainerFactory.GetInstance(code_info.ContainerType).LoadConfig <ConfigBase <T> >(code_info.InOutPath);

            if (Data.config_current == null)
            {
                Data.config_current = new ConfigBase <T>();
            }


            deleteList.Clear();
            ReloadOutLinkChache();
            Data.SyncData();
        }
Exemple #8
0
        /// <summary>
        /// 重新加载外链类缓存
        /// </summary>
        protected virtual void ReloadOutLinkChache()
        {
            if (outLinkRawData == null)
            {
                outLinkRawData = new Dictionary <int, object>();
            }
            else
            {
                outLinkRawData.Clear();
            }

            for (int i = 0; i < Data.CurrentClassFieldsCache.Count; i++)
            {
                //Bug fix: 自动做默认参数初始化
                if (Data.CurrentClassFieldsCache[i].config_editor_setting == null)
                {
                    Data.CurrentClassFieldsCache[i].config_editor_setting = new ControlProperty();
                    continue;
                }

                if (outLinkRawData.ContainsKey(Data.CurrentClassFieldsCache[i].config_editor_setting.OutCodeGenEditorID))
                {
                    continue;
                }

                if (Data.CurrentClassFieldsCache[i].config_editor_setting.OutCodeGenEditorID == 0)
                {
                    continue;
                }


                //重写外联编辑器逻辑
                var codeGenInfo = EditorConfig.GetCodeGenConfig()
                                  .SearchByOrderKey(Data.CurrentClassFieldsCache[i].config_editor_setting.OutCodeGenEditorID);

                if (codeGenInfo == null)
                {
                    Log("Can't find id In CodeGen Table" + Data.CurrentClassFieldsCache[i].config_editor_setting.OutCodeGenEditorID);
                    continue;
                }

                //查找非编辑器命名控件下
                Type classType = ReflectionHelper.GetCurrentAssemblyType(codeGenInfo.ClassType);

                //查找编辑器命名控件下
                if (classType == null)
                {
                    classType = GetType(codeGenInfo.ClassType);
                }


                if (classType == null)
                {
                    Log("Can't find calss " + codeGenInfo.ClassType);
                    continue;
                }

                var modelRaw = ConfigContainerFactory.GetInstance(codeGenInfo.ContainerType)
                               .LoadConfig(classType, codeGenInfo.InOutPath);

                if (modelRaw == null)
                {
                    Log(string.Format("Loading OutLink Class [{0}] Data failed !", codeGenInfo.ClassType));
                    return;
                }

                outLinkRawData.Add(Data.CurrentClassFieldsCache[i].config_editor_setting.OutCodeGenEditorID, modelRaw);

                Log(string.Format("Loading OutLink Class [{0}] Data Success !", codeGenInfo.ClassType));
            }
        }