Esempio n. 1
0
        public static void RefreshManager(bool Normalization = false)
        {
            mConfig = XConfig.GetConfig <VFSConfigModel>(VFSConst.ConfigFilePath_Resources);
            if (mConfig == null)
            {
                return;
            }
            if (Normalization)
            {
                VFSUtil.NormalizationConfig(mConfig);
            }

            if (!VFSUtil.CheckConfiguration(mConfig, out var errorCode, out var folderError))
            {
                string log_str = string.Empty;
                //配置文件校验未通过
                switch (errorCode)
                {
                case VFSErrorCode.ConfigureGroupsConflict:
                    //资源组规则未通过,log提示出来
                    log_str = VFSManagerEditorI18N.Log_ConfigureGroupsConflict;
                    if (folderError != null && folderError.Length > 0)
                    {
                        foreach (var f in folderError)
                        {
                            log_str += $"\nGroup [{f.GroupName}] , FolderPath: {f.FolderPath}";
                        }
                    }
                    Debug.LogError(log_str);
                    return;     //直接不继续往下执行了

                case VFSErrorCode.NoneGroup:
                    //没有配置任何资源组
                    //这个问题不报Error
                    return;

                case VFSErrorCode.SameGroupName:
                    log_str = VFSManagerEditorI18N.Log_SameGroupName;
                    Debug.LogError(log_str);
                    return;
                }
            }

            Groups.Clear();
            if (!mConfig.EnableVFS)
            {
                return;
            }

            //VFS Profile
            XDirectory.CreateIfNotExists(XEditorConst.EditorProjectSettingRootFolder);
            var profile_path = Path.Combine(XEditorConst.EditorProjectSettingRootFolder, VFSEditorConst.VFSProfileProjectSettingFileName);

            if (File.Exists(profile_path))
            {
                //load
                VFSProfileEditor = XConfig.GetJson <VFSProfileModel>(profile_path, AssetLoadType.SystemIO, false);
            }
            else
            {
                //create profile editor file in "ProjectSetting"
                initProfileRecord();
                //var json_text = JsonUtility.ToJson(VFSProfileEditor);
                XConfig.SaveJson(VFSProfileEditor, profile_path, AssetLoadType.SystemIO);
            }

            foreach (var group_opt in mConfig.Groups)
            {
                var _group_obj = new VFSEditorGroup(group_opt);
                Groups.Add(_group_obj);
                FolderPaths.AddRange(_group_obj.FolderPaths);
                foreach (var assetPath in _group_obj.AssetPaths)
                {
                    if (!AssetPaths.Contains(assetPath))
                    {
                        AssetPaths.Add(assetPath);
                    }
                }
            }

            LastRefreshManagerTime = System.DateTime.UtcNow;
        }