/// <summary> /// 检查文件夹是否冲突,如果冲突,返回true,冲突的文件夹路径会放在out参数里 /// </summary> /// <param name="simplify">简化检测,如果有发现冲突直接返回false结果,而不遍历所有数据进行判断</param> /// <param name="paths"></param> /// <returns></returns> public bool CheckFolderConflict(out List <string> paths, bool simplify = false) { List <string> result = new List <string>(); for (int i = 0; i < FolderPaths.Length; i++) { if (i > 0) { for (int j = 0; j < i; j++) { if (VFSUtil.IsSameOrSubPath(FolderPaths[i], FolderPaths[j], true)) { if (!result.Contains(FolderPaths[i])) { result.Add(FolderPaths[i]); } if (simplify) { paths = result; return(true); } } } } } paths = result; return(result.Count > 0); }
private bool mCurSaveBinary; //是否保存二进制文件 private void OnEnable() { if (VFS_Platform != null) { flag_platform_from_param = true; platform_from_param = VFS_Platform.Value; //如果参数给的是平台,那么要倒推出,当前该平台可用的分支 string[] main_package_branches = VFSManagerEditor.VersionManager.GetBranchNamesByMainPackage(platform_from_param); if (main_package_branches != null && main_package_branches.Length > 0) { match_branches_from_param.AddRange(main_package_branches); } string platform_name = XPlatformUtil.GetNameText(platform_from_param); string source_packages_folder_path = Path.Combine(VFSEditorConst.PROJECT_VFS_SOURCE_PACKAGES_ROOT_PATH, platform_name); string[] extension_groups_in_source_package_folder = VFSUtil.GetValidExtensionGroupNames(VFSUtil.GetExtensionPackageRootFolderInPackages(source_packages_folder_path)); foreach (var groupName in extension_groups_in_source_package_folder) { string[] group_branches = VFSManagerEditor.VersionManager.GetBranchNamesByExtensionGroup(platform_from_param, groupName); if (group_branches != null && group_branches.Length > 0) { match_branches_from_param.AddRange(group_branches); } } match_branches_from_param_arr = match_branches_from_param.ToArray(); } if (!BranchName.IsNullOrEmpty()) { flag_branchName_from_param = true; branchName_from_param = BranchName; isBrancNameFromParamValid = VFSManagerEditor.VersionManager.TryGetVersionBranch(branchName_from_param, out mCurBranch); mCurSelectBranchName = BranchName; } }
/// <summary> /// 保存BuildInfo /// </summary> /// <returns></returns> private void MakeBuildInfo(string packages_root_path) { var binfo = new BuildInfo(); binfo.BuildID = System.Guid.NewGuid().ToString(); //save main package string main_path = VFSUtil.GetMainPackage_BuildInfo_Path(packages_root_path); XFile.DeleteIfExists(main_path); XDirectory.CreateIfNotExists(Path.GetDirectoryName(main_path)); XConfig.SaveJson(binfo, main_path, AssetLoadType.SystemIO); //groups if (mEditorBuildInfo.list_total_extension != null && mEditorBuildInfo.list_total_extension.Count > 0) { foreach (var group in mEditorBuildInfo.list_total_extension) { string target_path = VFSUtil.GetExtensionGroup_BuildInfo_Path(packages_root_path, group); string group_root_path = VFSUtil.GetExtensionGroupFolder(packages_root_path, group); if (Directory.Exists(group_root_path)) { XFile.DeleteIfExists(target_path); XDirectory.CreateIfNotExists(Path.GetDirectoryName(target_path)); XConfig.SaveJson(binfo, target_path, AssetLoadType.SystemIO); } } } }
public static void CopyExtensionPackageToSreamingAssets(string extension_package_path, string platform, string group_name) { var target_path = VFSUtil.GetExtensionGroupFolder(VFSUtil.GetPackagesRootFolderInStreamingAssets(platform), group_name); XDirectory.DeleteIfExists(target_path); Directory.CreateDirectory(target_path); XDirectory.CopyDir(extension_package_path, extension_package_path); }
/// <summary> /// 在给定的根目录下,根据组名检查某个扩展包(组)是否有效 /// </summary> /// <param name="packages_root_path"></param> /// <param name="group_name"></param> /// <returns></returns> internal static bool IsValid_ExtensionGroup_InPackages(string packages_root_path, string group_name) { var arr = VFSUtil.GetValidExtensionGroupNames(VFSUtil.GetExtensionPackageRootFolderInPackages(packages_root_path)); if (arr == null || arr.Length == 0) { return(false); } return(arr.Contains(group_name)); }
/// <summary> /// 在给定的目录下,是否有任何一个有效的扩展组 /// </summary> /// <param name="packages_root_path"></param> /// <returns></returns> internal static bool IsAnyValidExtensionGroup_InPackages(string packages_root_path) { var arr = VFSUtil.GetValidExtensionGroupNames(VFSUtil.GetExtensionPackageRootFolderInPackages(packages_root_path)); if (arr == null || arr.Length == 0) { return(false); } return(true); }
public new string GetBuildInfoPath(string packages_root_path) { if (this.OverridePackagePath) { return(VFSUtil.GetExtensionGroup_BuildInfo_Path_InGroupPath(this.PackagePathSpecified)); } else { return(base.GetManifestFilePath(packages_root_path)); } }
/// <summary> /// 获取Manifest的文件地址 /// </summary> /// <param name="packages_root_path"></param> /// <returns></returns> public string GetManifestFilePath(string packages_root_path) { if (this.ExtensionGroup) { return(VFSUtil.GetExtensionGroups_AssetBundleManifests_FilePath(packages_root_path, this.GroupName)); } else { return(Path.Combine(packages_root_path, VFSConst.VFS_FOLDER_DATA, VFSConst.MainPackage_AssetBundleManifests_Folder, this.GroupName.GetMD5(true, true) + ".json")); } }
public void SaveGroupOptionFile(string package_root_path) { string target_path = VFSUtil.GetExtensionPackages_GroupOptions_FilePath(package_root_path, this.GroupName); XFile.DeleteIfExists(target_path); XDirectory.CreateIfNotExists(Path.GetDirectoryName(target_path)); string json = JsonUtility.ToJson(base.mOption); File.WriteAllText(target_path, json); }
public string GetUpgradableVersionPath(string package_root_path) { if (this.OverridePackagePath) { return(Path.Combine(this.PackagePathSpecified, VFSConst.Upgradable_Vesion_FileName)); } else { return(Path.Combine(VFSUtil.GetExtensionGroupFolder(package_root_path, this.GroupName), VFSConst.Upgradable_Vesion_FileName)); } }
public string GetVersionInfoPath(string packages_root_path) { if (this.OverridePackagePath) { return(Path.Combine(this.PackagePathSpecified, VFSConst.PakcageVersionFileName)); } else { return(VFSUtil.GetExtensionGroup_VersionInfo_Path(packages_root_path, this.GroupName)); } }
public string GetGroupRootFolder(string packages_root_path) { if (this.OverridePackagePath) { return(this.PackagePathSpecified); } else { return(VFSUtil.GetExtensionGroupFolder(packages_root_path, this.GroupName)); } }
public string GetBuildInfoPath(string packages_root_path) { if (this.ExtensionGroup) { return(VFSUtil.GetExtensionGroup_BuildInfo_Path(packages_root_path, this.GroupName)); } else { return(VFSUtil.GetMainPackage_BuildInfo_Path(packages_root_path)); } }
/// <summary> /// 在给定的目录中获取AssetBundle的路径 /// </summary> /// <param name="packages_root_path"></param> /// <param name="assetbundleName"></param> /// <returns></returns> public string GetAssetBundlePath(string packages_root_path, string assetbundleName) { if (this.ExtensionGroup) { return(VFSUtil.GetAssetBundlePathFromPackages(this.ExtensionGroup, packages_root_path, assetbundleName, this.GroupName)); } else { return(VFSUtil.GetAssetBundlePathFromPackages(this.ExtensionGroup, packages_root_path, assetbundleName)); } }
/// <summary> /// 检查给定的文件夹路径是否与组内的文件夹配置冲突(相同或者互为子路径),如果冲突,返回true /// </summary> /// <param name="folderPath"></param> /// <returns></returns> public bool CheckFolderConflict(string folderPath) { foreach (var path in FolderPaths) { if (VFSUtil.IsSameOrSubPath(folderPath, path, true)) { return(true); } } return(false); }
public void IsSubpathTest(string path1, string path2, bool mutual, bool expect) { if (expect == VFSUtil.IsSubpath(path1, path2, mutual)) { Assert.IsTrue(true); } else { TestContext.Out.WriteLine($"测试与预期不符, path1: {path1}, path2: { path2}, mutual: {mutual.ToString()}, 预期:{expect.ToString()}"); Assert.IsFalse(true); } }
private void SaveExtensionGroupInfo(string group_path, string group_name, XRuntimePlatform platform, long mainPackageVersionLimit, string ab_ext_name) { string file_path = VFSUtil.GetExtensionGroup_GroupInfo_Path_InGroupPath(group_path); var obj = new ExtensionGroupInfo { Platform = platform, GroupName = group_name, MainPackageVersionLimit = mainPackageVersionLimit, AssetBundleExtension = ab_ext_name }; XConfig.SaveJson(obj, file_path, AssetLoadType.SystemIO); }
/// <summary> /// 检查文件夹冲突,并将存在冲突的内容返回,如果没有冲突则返回值的Count = 0 /// </summary> /// <returns></returns> public List <string> CheckFolderConflict() { List <string> result = new List <string>(); for (int i = 0; i < FolderPaths.Length; i++) { if (i > 0) { for (int j = 0; j < i; j++) { if (VFSUtil.IsSameOrSubPath(FolderPaths[i], FolderPaths[j], true)) { if (!result.Contains(FolderPaths[i])) { result.Add(FolderPaths[i]); } } } } } return(result); }
private void MakeVFSConfig(string packages_root_path, VFSConfigModel config) { string config_path = VFSUtil.GetVFSConfigFilePath_InPackages(packages_root_path); string json = JsonUtility.ToJson(config); var json_obj = JsonUtility.FromJson <VFSConfigJson>(json); if (json_obj.Groups != null) { List <VFSGroupOption> options = new List <VFSGroupOption>(json_obj.Groups); for (int i = options.Count - 1; i >= 0; i--) { if (options[i].ExtensionGroup) { options.RemoveAt(i); continue; } } json_obj.Groups = options.ToArray(); } XConfig.SaveJson(json_obj, config_path, AssetLoadType.SystemIO); }
//Source packages 是指 VFS打包资源后的输出目录,里面包括"vfs_root","vfs_data"什么的那个目录 /// <summary> /// 检查在给定的根目录下,是否有有效的MainPackage文件 /// </summary> /// <returns></returns> internal static bool IsValid_MainPackage_InPackages(string packages_root_path, bool runtime_used = false) { //检查是否有vfs_root目录 string vfs_root = VFSUtil.GetMainPackageFolderInPackages(packages_root_path); if (!Directory.Exists(vfs_root)) { return(false); } //检查data目录 if (!Directory.Exists(VFSUtil.GetDataFolderInPackages(packages_root_path))) { return(false); } //检查build_info if (!File.Exists(VFSUtil.GetMainPackage_BuildInfo_Path(packages_root_path))) { return(false); } if (!runtime_used) { //检查asset_hash if (!File.Exists(VFSEditorUtil.GetMainPackage_AssetsHash_FilePath_InPackages(packages_root_path))) { return(false); } //检查editor build_info if (!File.Exists(VFSEditorUtil.Get_EditorBuildInfoPath(packages_root_path))) { return(false); } } return(true); }
/// <summary> /// 获取 Source Pakcges 下的 扩展组 的 版本信息 文件路径 /// </summary> /// <param name="platform_name"></param> /// <returns></returns> public static string Get_ExtensionGroups_PackageVersionFilePath_InSourcePackages(ref string platform_name, ref string groupName) { return(Path.Combine(VFSUtil.GetExtensionGroupFolder(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name), groupName), VFSConst.PakcageVersionFileName)); }
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; }
/// <summary> /// 获取Source Packages 下 存放 Main Packages 所有的 AssetBundleManifest 的文件的根目录 /// </summary> /// <param name="platform"></param> /// <returns></returns> public static string GetMainPackage_AssetBundleManifestsFolderPath_InSourcePackagesFolder(string platform) { return(VFSUtil.GetMainPackage_AssetBundleManifests_Folder(GetSourcePackagesFolderPath(platform))); }
private void RefreshData_Left_list() { if (mLeft_Select_Platform == null) { return; } var platform_name = XPlatformUtil.GetNameText(mLeft_Select_Platform.Value); string source_packages_root_path = VFSEditorUtil.GetSourcePackagesFolderPath(platform_name); string package_stream_root_path = VFSUtil.GetPackagesRootFolderInStreamingAssets(platform_name); //检查,StreamingAssets if (mDict_MainPackage_SourcePackage[mLeft_Select_Platform.Value] && mDict_MainPackage_StreamingAssets[mLeft_Select_Platform.Value]) { //两边都有,我们来看看两边的build_id是否一致 string build_info_source_path = VFSUtil.GetMainPackage_BuildInfo_Path(source_packages_root_path); string build_info_stream_path = VFSUtil.GetMainPackage_BuildInfo_Path(package_stream_root_path); if (File.Exists(build_info_stream_path) && File.Exists(build_info_source_path)) { try { var build_info_source = JsonUtility.FromJson <TinaX.VFSKitInternal.BuildInfo>(File.ReadAllText(build_info_source_path)); var build_info_stream = JsonUtility.FromJson <TinaX.VFSKitInternal.BuildInfo>(File.ReadAllText(build_info_stream_path)); if (build_info_source.BuildID != build_info_stream.BuildID) { main_package_not_same = true; } } catch { } } } else { main_package_not_same = false; } //扩展组的处理 mDict_ExtensionGroups_Info.Clear(); if (mDict_Extensions_SourcePackage[mLeft_Select_Platform.Value]) { string source_extensions_root_path = VFSUtil.GetExtensionPackageRootFolderInPackages(source_packages_root_path); string[] group_names = VFSUtil.GetValidExtensionGroupNames(source_extensions_root_path); foreach (var group in group_names) { //streamingassets 中存在嘛 if (VFSUtil.IsValidExtensionPackage(VFSUtil.GetExtensionGroupFolder(package_stream_root_path, group))) { //存在,检查build_id string build_id_path_source = VFSUtil.GetExtensionGroup_BuildInfo_Path(source_packages_root_path, group); string build_id_path_stream = VFSUtil.GetExtensionGroup_BuildInfo_Path(package_stream_root_path, group); try { var b_info_source = JsonUtility.FromJson <TinaX.VFSKitInternal.BuildInfo>(File.ReadAllText(build_id_path_source)); var b_info_stream = JsonUtility.FromJson <TinaX.VFSKitInternal.BuildInfo>(File.ReadAllText(build_id_path_stream)); if (b_info_source.BuildID == b_info_stream.BuildID) { mDict_ExtensionGroups_Info.Add(group, 2); } else { mDict_ExtensionGroups_Info.Add(group, 1); } } catch { } if (!mDict_ExtensionGroups_Info.ContainsKey(group)) { mDict_ExtensionGroups_Info.Add(group, 2); } } else { // 不存在 mDict_ExtensionGroups_Info.Add(group, 0); } } } mFlag_RefreshData_left_platform = mLeft_Select_Platform; mFlag_RefreshData_left = true; }
/// <summary> /// 添加版本记录 /// </summary> /// <param name=""></param> public void AddVersionRecord(string branchName, long versionCode, string versionName, string versionDesc, bool saveBinary, bool dialog = true, bool log = true) { //编辑器那边限制了不能添加“比最大版本号更小的版本号”的版本,(也就是说版本号只能变大),但是这里实际上没做这个限制。以后如果有需要,可以让编辑器UI上去掉限制。 if (mDict_Branches.TryGetValue(branchName, out var branch)) { //判断一下版本号啦 if (versionCode >= 0 && !branch.IsVersionCodeExists(versionCode)) { bool isMainPackage = (branch.BType == VersionBranch.BranchType.MainPackage); bool flag_process_error = false; //处理文件过程中如果出错则中断操作且不记录数据 string platform_name = XPlatformUtil.GetNameText(branch.Platform); string source_packages_folder_path = VFSEditorUtil.GetSourcePackagesFolderPath(platform_name); string data_folder = VFSEditorUtil.GetVersionDataFolderPath_InProjectVersion(branch.BranchName, versionCode); //存放数据的地方 string build_id = string.Empty; try { XDirectory.DeleteIfExists(data_folder, true); Directory.CreateDirectory(data_folder); //复制并存档assets_hash文件 string assets_hash_path = isMainPackage ? VFSEditorUtil.GetMainPackage_AssetsHashFilePath_InSourcePackagesFolder(platform_name) : VFSEditorUtil.GetExtensionGroup_AssetsHashFilePath_InSourcePackagesFolder(platform_name, branch.ExtensionGroupName); string assets_hash_target_path = Path.Combine(data_folder, VFSConst.AssetsHashFileName); if (File.Exists(assets_hash_path)) { File.Copy(assets_hash_path, assets_hash_target_path, true); } //复制并存档Manifest文件 string manifest_target_path = VFSEditorUtil.GetVersionData_Manifest_FolderOrFilePath(!isMainPackage, branchName, versionCode); string manifest_path = isMainPackage ? VFSEditorUtil.GetMainPackage_AssetBundleManifestsFolderPath_InSourcePackagesFolder(platform_name) : VFSEditorUtil.GetExtensionGroup_AssetBundleManifestPath_InInSourcePackagesFolder(platform_name, branch.ExtensionGroupName); if (isMainPackage) { if (Directory.Exists(manifest_path)) { XDirectory.CopyDir(manifest_path, manifest_target_path); } } else { if (File.Exists(manifest_path)) { File.Copy(manifest_path, manifest_target_path); } } //复制并存档AssetBundleHashs string ab_hash_path = isMainPackage ? VFSEditorUtil.GetMainPackage_AssetBundle_HashFiles_FolderPath_InSourcePackagesFolder(platform_name) : VFSEditorUtil.GetExtensionGroup_AssetBundle_HashFiles_Path_InInSourcePackagesFolder(platform_name, branch.ExtensionGroupName); string ab_hash_target_path = VFSEditorUtil.GetVersionData_AssetBundle_HashFile_FolderOrFilePath(!isMainPackage, branchName, versionCode); if (isMainPackage) { if (Directory.Exists(ab_hash_path)) { XDirectory.CopyDir(ab_hash_path, ab_hash_target_path); } } else { if (File.Exists(ab_hash_path)) { File.Copy(ab_hash_path, ab_hash_target_path); } } //复制并存档vfs config (main package) if (isMainPackage) { string vfs_config_path = VFSUtil.GetVFSConfigFilePath_InPackages(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name)); if (File.Exists(vfs_config_path)) { string target_path = Path.Combine(data_folder, VFSConst.Config_Runtime_FileName); File.Copy(vfs_config_path, target_path, true); } } //Group Options if (!isMainPackage) { string group_option_path = VFSUtil.GetExtensionPackages_GroupOptions_FilePath(source_packages_folder_path, branch.ExtensionGroupName); if (File.Exists(group_option_path)) { string target_path = Path.Combine(data_folder, VFSConst.ExtensionGroup_GroupOption_FileName); File.Copy(group_option_path, target_path, true); } } //Group Info if (!isMainPackage) { string group_info_path = VFSUtil.GetExtensionGroup_GroupInfo_Path_InGroupPath(VFSUtil.GetExtensionGroupFolder(source_packages_folder_path, branch.ExtensionGroupName)); if (File.Exists(group_info_path)) { string target_path = Path.Combine(data_folder, VFSConst.VFS_ExtensionGroupInfo_FileName); File.Copy(group_info_path, target_path, true); } } //复制并存档editor build info string editor_build_info_path = VFSEditorUtil.Get_EditorBuildInfoPath(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name)); if (File.Exists(editor_build_info_path)) { string target_path = VFSEditorUtil.GetVersionData_EditorBuildInfo_Path(branchName, versionCode); File.Copy(editor_build_info_path, target_path); } //复制并存档 build info string build_info_path = VFSUtil.GetMainPackage_BuildInfo_Path(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name)); if (File.Exists(build_info_path)) { //存档 string target_path = VFSEditorUtil.GetVersionData_BuildInfo_Path(branchName, versionCode); File.Copy(build_info_path, target_path); //反写版本信息到source package string build_info_json = File.ReadAllText(target_path, Encoding.UTF8); var obj = JsonUtility.FromJson <BuildInfo>(build_info_json); build_id = obj.BuildID; //写出版本信息 var version_info = new PackageVersionInfo { version = versionCode, versionName = versionName, buildId = obj.BuildID, branch = branch.BranchName }; string version_info_path = isMainPackage ? VFSEditorUtil.Get_MainPackage_PackageVersionFilePath_InSourcePackages(platform_name) : VFSEditorUtil.Get_ExtensionGroups_PackageVersionFilePath_InSourcePackages(ref platform_name, ref branch.ExtensionGroupName); XFile.DeleteIfExists(version_info_path); XConfig.SaveJson(version_info, version_info_path, AssetLoadType.SystemIO); //检查当前StreamingAssets中是否有与之build id一致的情况,如果有,也写出 if (isMainPackage) { string buildinfo_in_stream = VFSUtil.GetMainPackage_BuildInfo_Path(VFSUtil.GetPackagesRootFolderInStreamingAssets(platform_name)); if (File.Exists(buildinfo_in_stream)) { try { var obj_stream = XConfig.GetJson <BuildInfo>(buildinfo_in_stream, AssetLoadType.SystemIO, false); if (obj_stream.BuildID == obj.BuildID) { //一致,写出 string target_stream = VFSUtil.GetMainPackage_VersionInfo_Path(VFSUtil.GetPackagesRootFolderInStreamingAssets(platform_name)); XConfig.SaveJson(version_info, target_stream, AssetLoadType.SystemIO); } } catch { } } } else { string buildinfo_in_stream = VFSUtil.GetExtensionGroup_BuildInfo_Path(VFSUtil.GetPackagesRootFolderInStreamingAssets(platform_name), branch.ExtensionGroupName); if (File.Exists(buildinfo_in_stream)) { try { var obj_stream = XConfig.GetJson <BuildInfo>(buildinfo_in_stream, AssetLoadType.SystemIO, false); if (obj_stream.BuildID == obj.BuildID) { //一致,写出 string target_stream = VFSUtil.GetExtensionGroup_VersionInfo_Path(VFSUtil.GetPackagesRootFolderInStreamingAssets(platform_name), branch.ExtensionGroupName); XConfig.SaveJson(version_info, target_stream, AssetLoadType.SystemIO); } } catch { } } } } } catch (Exception e) { XDirectory.DeleteIfExists(data_folder, true); flag_process_error = true; throw e; } //保存二进制文件 if (saveBinary && !flag_process_error) { string binary_path = VFSEditorUtil.Get_AssetsBinaryFolderPath_InVersion(branchName, versionCode); try { long total_count = 0; //把所有二进制文件直接全拷进去 string binary_path_temp = Path.Combine(binary_path, "temp"); string binary_path_temp_remote = Path.Combine(binary_path, "temp_remote"); XDirectory.DeleteIfExists(binary_path_temp, true); Directory.CreateDirectory(binary_path_temp); if (isMainPackage) { XDirectory.DeleteIfExists(binary_path_temp_remote, true); Directory.CreateDirectory(binary_path_temp_remote); } //移动文件 if (isMainPackage) { string local_path = VFSEditorUtil.Get_MainPackage_AssetsFolderPath_InSourcePackages(platform_name); int local_path_len = local_path.Length + 1; string[] local_files = Directory.GetFiles(local_path, "*.*", SearchOption.AllDirectories); if (local_files != null && local_files.Length > 0) { ArrayUtil.RemoveDuplicationElements(ref local_files); foreach (var item in local_files) { total_count++; string pure_path = item.Substring(local_path_len, item.Length - local_path_len); string target_path = Path.Combine(binary_path_temp, pure_path); XDirectory.CreateIfNotExists(Path.GetDirectoryName(target_path)); File.Copy(item, target_path); } } string remote_path = VFSEditorUtil.Get_MainPackage_RemoteAssetsFolderPath_InSourcePackages(platform_name); if (Directory.Exists(remote_path)) { int remote_path_len = remote_path.Length + 1; string[] remote_files = Directory.GetFiles(remote_path, "*.*", SearchOption.AllDirectories); if (remote_files != null && remote_files.Length > 0) { total_count++; ArrayUtil.RemoveDuplicationElements(ref remote_files); foreach (var item in remote_files) { string pure_path = item.Substring(remote_path_len, item.Length - remote_path_len); string target_path = Path.Combine(binary_path_temp_remote, pure_path); XDirectory.CreateIfNotExists(Path.GetDirectoryName(target_path)); File.Copy(item, target_path); } } } } else { string group_path = VFSEditorUtil.Get_ExtensionGroupFolderPath_InSourcePackages(platform_name, branch.ExtensionGroupName); int group_path_len = group_path.Length + 1; string[] group_files = Directory.GetFiles(group_path, "*.*", SearchOption.AllDirectories); if (group_files != null && group_files.Length > 0) { total_count++; ArrayUtil.RemoveDuplicationElements(ref group_files); foreach (var item in group_files) { string pure_path = item.Substring(group_path_len, item.Length - group_path_len); string target_path = Path.Combine(binary_path_temp, pure_path); XDirectory.CreateIfNotExists(Path.GetDirectoryName(target_path)); File.Copy(item, target_path); } } } long zip_counter = 0; int zip_counter_t = 0; //打包 string zip_file_path = Path.Combine(binary_path, VFSEditorConst.VFS_VERSION_AssetsBinary_Zip_Name); ZipUtil.ZipDirectory(binary_path_temp, zip_file_path, fileName => { if (log || dialog) { zip_counter++; if (total_count > 100) { zip_counter_t++; if (zip_counter_t >= 20) { zip_counter_t = 0; if (log) { Debug.Log($" Create Zip: {zip_counter}/{total_count}"); } if (dialog) { EditorUtility.DisplayProgressBar("Create Zip", $"{zip_counter}/{total_count}\n{fileName}", zip_counter / total_count); } } } else { if (log) { Debug.Log($" Create Zip: {zip_counter}/{total_count} : {fileName}"); } if (dialog) { EditorUtility.DisplayProgressBar("Create Zip", $"{zip_counter}/{total_count}\n{fileName}", zip_counter / total_count); } } } }); if (isMainPackage) { string zip_file_path_remote = Path.Combine(binary_path, VFSEditorConst.VFS_VERSION_AssetsBinary_REMOTE_Zip_Name); zip_counter = 0; zip_counter_t = 0; ZipUtil.ZipDirectory(binary_path_temp_remote, zip_file_path_remote, fileName => { if (log || dialog) { zip_counter++; if (total_count > 100) { zip_counter_t++; if (zip_counter_t >= 20) { zip_counter_t = 0; if (log) { Debug.Log($" Create Zip: {zip_counter}/{total_count}"); } if (dialog) { EditorUtility.DisplayProgressBar("Create Zip", $"{zip_counter}/{total_count}\n{fileName}", zip_counter / total_count); } } } else { if (log) { Debug.Log($" Create Zip: {zip_counter}/{total_count} : {fileName}"); } if (dialog) { EditorUtility.DisplayProgressBar("Create Zip", $"{zip_counter}/{total_count}\n{fileName}", zip_counter / total_count); } } } }); } if (dialog) { EditorUtility.ClearProgressBar(); //上面这个应该是同步方法,不会有时间错乱。(吧 } //删除temp XDirectory.DeleteIfExists(binary_path_temp); XDirectory.DeleteIfExists(binary_path_temp_remote); } catch (Exception e) { flag_process_error = true; XDirectory.DeleteIfExists(binary_path); throw e; } } if (!flag_process_error) { //登记到索引 var vr = new VersionRecord() { versionCode = versionCode, versionName = versionName, desc = versionDesc, build_id = build_id }; //记录版本 branch.AddVersion(ref vr); //保存版本索引 SaveBranchFile(ref branch); } } } }
/// <summary> /// 准备GUI需要用到的数据 /// </summary> private void RefreshDatas() { source_packages_counter = 0; if (mDict_MainPackage_SourcePackage == null) { mDict_MainPackage_SourcePackage = new Dictionary <XRuntimePlatform, bool>(); } else { mDict_MainPackage_SourcePackage.Clear(); } if (mDict_MainPackage_StreamingAssets == null) { mDict_MainPackage_StreamingAssets = new Dictionary <XRuntimePlatform, bool>(); } else { mDict_MainPackage_StreamingAssets.Clear(); } if (mDict_Extensions_SourcePackage == null) { mDict_Extensions_SourcePackage = new Dictionary <XRuntimePlatform, bool>(); } else { mDict_Extensions_SourcePackage.Clear(); } if (mDict_Extensions_StreamingAssets == null) { mDict_Extensions_StreamingAssets = new Dictionary <XRuntimePlatform, bool>(); } else { mDict_Extensions_StreamingAssets.Clear(); } foreach (XRuntimePlatform platform in Enum.GetValues(typeof(XRuntimePlatform))) { string platform_name = XPlatformUtil.GetNameText(platform); //source packages string source_packages_path = VFSEditorUtil.GetSourcePackagesFolderPath(platform_name); mDict_MainPackage_SourcePackage.Add(platform, VFSEditorUtil.IsValid_MainPackage_InPackages(source_packages_path)); mDict_Extensions_SourcePackage.Add(platform, VFSEditorUtil.IsAnyValidExtensionGroup_InPackages(source_packages_path)); if (mDict_MainPackage_SourcePackage[platform] || mDict_Extensions_SourcePackage[platform]) { source_packages_counter++; } //streamingassets string packages_stream_path = VFSUtil.GetPackagesRootFolderInStreamingAssets(platform_name); mDict_MainPackage_StreamingAssets.Add(platform, VFSEditorUtil.IsValid_MainPackage_InPackages(packages_stream_path, true)); mDict_Extensions_StreamingAssets.Add(platform, VFSEditorUtil.IsAnyValidExtensionGroup_InPackages(packages_stream_path)); if (mDict_MainPackage_StreamingAssets[platform] || mDict_Extensions_StreamingAssets[platform]) { packages_stream_counter++; } } mFlag_RefreshData = true; }
private void OnGUI() { if (!mFlag_RefreshData) { this.RefreshDatas(); } EditorGUILayout.BeginHorizontal(GUILayout.Width(width_total)); //左边列表-source packages EditorGUILayout.BeginVertical(mStyle_box, GUILayout.Width(width_left_area)); GUILayout.Label("Source Packages:"); if (source_packages_counter > 0) { v2_list_left = EditorGUILayout.BeginScrollView(v2_list_left); foreach (var item in mDict_MainPackage_SourcePackage) { if (item.Value || mDict_Extensions_SourcePackage[item.Key]) { if (mLeft_Select_Platform != null && mLeft_Select_Platform == item.Key) { GUILayout.Label($"[{item.Key.ToString()}]", mStyle_select_label); } else { if (GUILayout.Button(item.Key.ToString())) { mLeft_Select_Platform = item.Key; } } } } EditorGUILayout.EndScrollView(); } else { GUILayout.FlexibleSpace(); GUILayout.Label(IsChinese ? "没有任何已构建的资源" : "No any built files", mStyle_center_large_label); GUILayout.FlexibleSpace(); } EditorGUILayout.EndVertical(); //中间 EditorGUILayout.BeginVertical(GUILayout.Width(width_center_area)); v2_list_center = EditorGUILayout.BeginScrollView(v2_list_center); //中间-source packages EditorGUILayout.BeginVertical(mStyle_box_center, GUILayout.MinHeight((this.position.height - 25) / 2)); if (mLeft_Select_Platform == null) { GUILayout.FlexibleSpace(); GUILayout.Label(@"(_ _)。゜zzZ"); GUILayout.FlexibleSpace(); } else { if (!mFlag_RefreshData_left || mFlag_RefreshData_left_platform == null || mFlag_RefreshData_left_platform.Value != mLeft_Select_Platform.Value) { RefreshData_Left_list(); } string platform_name = XPlatformUtil.GetNameText(mLeft_Select_Platform.Value); GUILayout.Label(IsChinese ? "已构建的资源" : "Built Assets"); GUILayout.Label((IsChinese ? "平台:" : "Platform: ") + mLeft_Select_Platform.ToString() + " / " + platform_name); if (mDict_MainPackage_SourcePackage[mLeft_Select_Platform.Value]) { if (!mDict_MainPackage_StreamingAssets[mLeft_Select_Platform.Value]) { //source有,stream没有,显示复制选项 if (GUILayout.Button(IsChinese?"复制 主包 到StreamingAssets":"Copy Main Package To StreamingAssets")) { VFSEditorUtil.CopyToStreamingAssets(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name), platform_name, false, true); AssetDatabase.Refresh(); RefreshDatas(); } //source有,stream没有,显示复制选项 if (GUILayout.Button(IsChinese ? "复制 全部 到StreamingAssets" : "Copy All Packages To StreamingAssets")) { VFSEditorUtil.CopyToStreamingAssets(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name), platform_name, false, false); AssetDatabase.Refresh(); RefreshDatas(); } } else { if (main_package_not_same) { EditorGUILayout.HelpBox(IsChinese?"StreamingAssets有 主包 资源,但与构建目录中的资源不一致。": "StreamingAssets has the main package resource, but it is not consistent with the resources in the build directory.", MessageType.None); //source有,stream没有,显示复制选项 if (GUILayout.Button(IsChinese ? "复制 主包 到StreamingAssets" : "Copy Main Package To StreamingAssets")) { VFSEditorUtil.CopyToStreamingAssets(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name), platform_name, false, true); AssetDatabase.Refresh(); RefreshDatas(); } } } } if (mDict_Extensions_SourcePackage[mLeft_Select_Platform.Value]) { if (mDict_ExtensionGroups_Info.Count > 0) { GUILayout.Space(5); foreach (var item in mDict_ExtensionGroups_Info) { if (item.Value != 2) { if (GUILayout.Button(IsChinese ? $"复制扩展组 {item.Key} 到StreamingAssets" : $"Copy Extension Group \"{item.Key}\" To StreamingAsssets")) { string extension_group_source_path = VFSUtil.GetExtensionGroupFolder(VFSEditorUtil.GetSourcePackagesFolderPath(platform_name), item.Key); VFSEditorUtil.CopyExtensionPackageToSreamingAssets(extension_group_source_path, platform_name, item.Key); AssetDatabase.Refresh(); RefreshDatas(); RefreshData_Left_list(); Refresh_Right_list(); } } } } } } EditorGUILayout.EndVertical(); GUILayout.Space(10); //中间-streamingassets EditorGUILayout.BeginVertical(mStyle_box_center, GUILayout.MinHeight((this.position.height - 25) / 2)); if (mRight_Select_Platform == null) { GUILayout.FlexibleSpace(); GUILayout.Label(@"(๑•̀ㅂ•)و✧́"); GUILayout.FlexibleSpace(); } else { GUILayout.Label("StreamingAssets"); GUILayout.Label((IsChinese ? "平台:" : "Platform: ") + mRight_Select_Platform.ToString() + " / " + XPlatformUtil.GetNameText(mRight_Select_Platform.Value)); if (GUILayout.Button(IsChinese ? "删除资源" : "Delete Assets")) { if (EditorUtility.DisplayDialog("sure?", IsChinese?"确定要删除吗":"Are you sure to delete?", IsChinese ? "删它!" : "Delete", IsChinese ? "取消" : "Cancel")) { VFSEditorUtil.DeletePackagesFromStreamingAssets(XPlatformUtil.GetNameText(mRight_Select_Platform.Value)); mDict_Extensions_StreamingAssets[mRight_Select_Platform.Value] = false; mDict_MainPackage_StreamingAssets[mRight_Select_Platform.Value] = false; mRight_Select_Platform = null; mFlag_RefreshData_right = false; AssetDatabase.Refresh(); RefreshDatas(); RefreshData_Left_list(); } } } EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); //右边 EditorGUILayout.BeginVertical(mStyle_box, GUILayout.Width(width_right_area)); GUILayout.Label("StreamingAssets:"); if (packages_stream_counter > 0) { v2_list_right = EditorGUILayout.BeginScrollView(v2_list_right); foreach (var item in mDict_MainPackage_StreamingAssets) { if (item.Value || mDict_Extensions_StreamingAssets[item.Key]) { if (mRight_Select_Platform != null && mRight_Select_Platform == item.Key) { GUILayout.Label($"[{item.Key.ToString()}]", mStyle_select_label); } else { if (GUILayout.Button(item.Key.ToString())) { mRight_Select_Platform = item.Key; } } } } EditorGUILayout.EndScrollView(); } else { GUILayout.FlexibleSpace(); GUILayout.Label(IsChinese ? "没有任何有效的的包" : "No any valid packages", mStyle_center_large_label); GUILayout.FlexibleSpace(); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); }
/// <summary> /// 获取Source Packages 下 存放 Main Packages 所有的 AssetBundle的Hash 的文件的根目录 /// </summary> /// <param name="platform"></param> /// <returns></returns> public static string GetMainPackage_AssetBundle_HashFiles_FolderPath_InSourcePackagesFolder(string platform) { return(VFSUtil.GetMainPackageAssetBundleHashFilesRootPath(GetSourcePackagesFolderPath(platform))); }
/// <summary> /// 获取Source Packages 下 扩展组 的 AssetBundle的Hash 的文件的路径 /// </summary> /// <param name="platform"></param> /// <param name="group_name"></param> /// <returns></returns> public static string GetExtensionGroup_AssetBundle_HashFiles_Path_InInSourcePackagesFolder(string platform, string group_name) { return(VFSUtil.GetExtensionGroup_AssetBundleHashFileFilePath(GetSourcePackagesFolderPath(platform), group_name)); }
public void SetOptions(VFSGroupOption option) { mOption = option; GroupName = option.GroupName; foreach (var path in option.FolderPaths) { if (!path.EndsWith("/")) { string _path = path + "/"; FolderPaths.Add(_path); FolderPathsLower.Add(_path.ToLower()); } else { FolderPaths.Add(path); FolderPathsLower.Add(path.ToLower()); } } foreach (var path in option.AssetPaths) { AssetPaths.Add(path); AssetPathsLower.Add(path.ToLower()); } //忽略子目录,子目录必须是FolderPaths的子目录,这里初始化的时候过滤一下无效的配置,节省后面的运算 foreach (var path in option.IgnoreSubPath) { string _path = (path.EndsWith("/")) ? path : path + "/"; string path_lower = _path.ToLower(); foreach (var folder in FolderPathsLower) { if (VFSUtil.IsSubpath(path_lower, folder, false)) { IgnoreSubpath.Add(_path); IgnoreSubpathLower.Add(path_lower); break; } } } //忽略后缀名 foreach (var ext in option.IngnoreExtName) { IgnoreExtensionLower.Add(ext.StartsWith(".") ? ext.ToLower() : "." + ext.ToLower()); } //特殊打包规则 foreach (var rule in option.FolderSpecialBuildRules) { bool flag = true; if (rule.DevType == FolderBuildDevelopType.normal && rule.BuildType == FolderBuildType.normal) { flag = false;//这是条没必要的规则 } if (rule.FolderPath.IsNullOrEmpty() || rule.FolderPath.IsNullOrWhiteSpace()) { flag = false; } string _folder_path = (rule.FolderPath.EndsWith("/")) ? rule.FolderPath : rule.FolderPath + "/"; string _folder_lower = _folder_path.ToLower(); if (!IsSubfolderOfFolderList(_folder_path)) { flag = false; } if (flag) { var _rule = rule; _rule.FolderPath = _folder_path; var lower_rule = rule; lower_rule.FolderPath = _folder_lower; SpecialFolderBuildRules.Add(_rule); SpecialFolderBuildRulesLower.Add(lower_rule); } } }