From eafdb8cd31887b7a095526d85a380ce0aa64c18d Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 4 May 2022 21:24:51 +0800 Subject: [PATCH] Update AssetBundleCollector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AssetBundleGrouper变更为AssetBundleCollector --- .../AssetBundleBuilderWindow.cs | 2 +- .../AssetBundleRuntimeBuilder.cs | 2 +- .../AssetBundleBuilder/BuildAssetInfo.cs | 4 +- .../AssetBundleBuilder/BuildMapCreater.cs | 4 +- .../BuildTasks/TaskCreateReport.cs | 4 +- ...Grouper.meta => AssetBundleCollector.meta} | 0 .../AssetBundleCollector.cs | 54 ++--- .../AssetBundleCollector.cs.meta | 0 .../AssetBundleCollectorConfig.cs} | 72 +++--- .../AssetBundleCollectorConfig.cs.meta} | 0 .../AssetBundleCollectorGroup.cs} | 12 +- .../AssetBundleCollectorGroup.cs.meta} | 0 .../AssetBundleCollectorSetting.cs} | 16 +- .../AssetBundleCollectorSetting.cs.meta} | 0 .../AssetBundleCollectorSettingData.cs} | 54 ++--- .../AssetBundleCollectorSettingData.cs.meta} | 0 .../AssetBundleCollectorWindow.cs} | 224 +++++++++--------- .../AssetBundleCollectorWindow.cs.meta} | 0 .../AssetBundleCollectorWindow.uxml} | 12 +- .../AssetBundleCollectorWindow.uxml.meta} | 0 .../CollectAssetInfo.cs | 0 .../CollectAssetInfo.cs.meta | 0 .../DefaultAddressRule.cs | 4 +- .../DefaultAddressRule.cs.meta | 0 .../DefaultFilterRule.cs | 0 .../DefaultFilterRule.cs.meta | 0 .../DefaultPackRule.cs | 4 +- .../DefaultPackRule.cs.meta | 0 .../ECollectorType.cs | 0 .../ECollectorType.cs.meta | 0 .../IAddressRule.cs | 6 +- .../IAddressRule.cs.meta | 0 .../IFilterRule.cs | 0 .../IFilterRule.cs.meta | 0 .../IPackRule.cs | 8 +- .../IPackRule.cs.meta | 0 Assets/YooAsset/Editor/EditorDefine.cs | 2 +- .../ShaderVariantCollector.cs | 2 +- .../Loader/DependAssetBundleGrouper.cs | 4 +- .../AssetSystem/Provider/BundledProvider.cs | 4 +- 40 files changed, 247 insertions(+), 247 deletions(-) rename Assets/YooAsset/Editor/{AssetBundleGrouper.meta => AssetBundleCollector.meta} (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/AssetBundleCollector.cs (76%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/AssetBundleCollector.cs.meta (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper/AssetBundleGrouperConfig.cs => AssetBundleCollector/AssetBundleCollectorConfig.cs} (68%) rename Assets/YooAsset/Editor/{AssetBundleGrouper/AssetBundleGrouperConfig.cs.meta => AssetBundleCollector/AssetBundleCollectorConfig.cs.meta} (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper/AssetBundleGrouper.cs => AssetBundleCollector/AssetBundleCollectorGroup.cs} (87%) rename Assets/YooAsset/Editor/{AssetBundleGrouper/AssetBundleGrouper.cs.meta => AssetBundleCollector/AssetBundleCollectorGroup.cs.meta} (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper/AssetBundleGrouperSetting.cs => AssetBundleCollector/AssetBundleCollectorSetting.cs} (82%) rename Assets/YooAsset/Editor/{AssetBundleGrouper/AssetBundleGrouperSetting.cs.meta => AssetBundleCollector/AssetBundleCollectorSetting.cs.meta} (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper/AssetBundleGrouperSettingData.cs => AssetBundleCollector/AssetBundleCollectorSettingData.cs} (83%) rename Assets/YooAsset/Editor/{AssetBundleGrouper/AssetBundleGrouperSettingData.cs.meta => AssetBundleCollector/AssetBundleCollectorSettingData.cs.meta} (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper/AssetBundleGrouperWindow.cs => AssetBundleCollector/AssetBundleCollectorWindow.cs} (64%) rename Assets/YooAsset/Editor/{AssetBundleGrouper/AssetBundleGrouperWindow.cs.meta => AssetBundleCollector/AssetBundleCollectorWindow.cs.meta} (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper/AssetBundleGrouperWindow.uxml => AssetBundleCollector/AssetBundleCollectorWindow.uxml} (82%) rename Assets/YooAsset/Editor/{AssetBundleGrouper/AssetBundleGrouperWindow.uxml.meta => AssetBundleCollector/AssetBundleCollectorWindow.uxml.meta} (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/CollectAssetInfo.cs (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/CollectAssetInfo.cs.meta (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/DefaultAddressRule.cs (89%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/DefaultAddressRule.cs.meta (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/DefaultFilterRule.cs (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/DefaultFilterRule.cs.meta (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/DefaultPackRule.cs (98%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/DefaultPackRule.cs.meta (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/ECollectorType.cs (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/ECollectorType.cs.meta (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/IAddressRule.cs (83%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/IAddressRule.cs.meta (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/IFilterRule.cs (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/IFilterRule.cs.meta (100%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/IPackRule.cs (84%) rename Assets/YooAsset/Editor/{AssetBundleGrouper => AssetBundleCollector}/IPackRule.cs.meta (100%) diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs index ea76a1e..0a9f831 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs @@ -176,7 +176,7 @@ namespace YooAsset.Editor buildParameters.BuildVersion = _buildVersionField.value; buildParameters.BuildinTags = _buildTagsField.value; buildParameters.VerifyBuildingResult = true; - buildParameters.EnableAddressable = AssetBundleGrouperSettingData.Setting.EnableAddressable; + buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable; buildParameters.AppendFileExtension = _appendExtensionToggle.value; buildParameters.EncryptionServices = CreateEncryptionServicesInstance(); buildParameters.CompressOption = (ECompressOption)_compressionField.value; diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleRuntimeBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleRuntimeBuilder.cs index c1201c3..a010830 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleRuntimeBuilder.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleRuntimeBuilder.cs @@ -19,7 +19,7 @@ namespace YooAsset.Editor buildParameters.BuildMode = EBuildMode.FastRunBuild; buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion; buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags; - buildParameters.EnableAddressable = AssetBundleGrouperSettingData.Setting.EnableAddressable; + buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable; AssetBundleBuilder builder = new AssetBundleBuilder(); bool buildResult = builder.Run(buildParameters); diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs index 0daded9..d360fc5 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs @@ -147,11 +147,11 @@ namespace YooAsset.Editor if (IsRawAsset) throw new Exception("Should never get here !"); - if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders) + if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders) { if (IsShaderAsset) { - string shareBundleName = $"{AssetBundleGrouperSettingData.Setting.ShadersBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}"; + string shareBundleName = $"{AssetBundleCollectorSettingData.Setting.ShadersBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}"; _shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower(); return; } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs index feafa68..0ff3610 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs @@ -16,10 +16,10 @@ namespace YooAsset.Editor Dictionary buildAssetDic = new Dictionary(1000); // 1. 检测配置合法性 - AssetBundleGrouperSettingData.Setting.CheckConfigError(); + AssetBundleCollectorSettingData.Setting.CheckConfigError(); // 2. 获取所有主动收集的资源 - List allCollectAssets = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets(); + List allCollectAssets = AssetBundleCollectorSettingData.Setting.GetAllCollectAssets(); // 3. 剔除未被引用的依赖资源 List removeDependList = new List(); diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs index 05832b5..f05c882 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs @@ -33,8 +33,8 @@ namespace YooAsset.Editor buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable; buildReport.Summary.EnableAutoCollect = buildParameters.Parameters.EnableAutoCollect; buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension; - buildReport.Summary.AutoCollectShaders = AssetBundleGrouperSettingData.Setting.AutoCollectShaders; - buildReport.Summary.ShadersBundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName; + buildReport.Summary.AutoCollectShaders = AssetBundleCollectorSettingData.Setting.AutoCollectShaders; + buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName; buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ? "null" : buildParameters.Parameters.EncryptionServices.GetType().FullName; diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper.meta b/Assets/YooAsset/Editor/AssetBundleCollector.meta similarity index 100% rename from Assets/YooAsset/Editor/AssetBundleGrouper.meta rename to Assets/YooAsset/Editor/AssetBundleCollector.meta diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleCollector.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs similarity index 76% rename from Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleCollector.cs rename to Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs index 5c92bed..1716a8b 100644 --- a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleCollector.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs @@ -51,13 +51,13 @@ namespace YooAsset.Editor if (CollectorType == ECollectorType.None) return false; - if (AssetBundleGrouperSettingData.HasAddressRuleName(AddressRuleName) == false) + if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false) return false; - if (AssetBundleGrouperSettingData.HasPackRuleName(PackRuleName) == false) + if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false) return false; - if (AssetBundleGrouperSettingData.HasFilterRuleName(FilterRuleName) == false) + if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false) return false; return true; @@ -74,20 +74,20 @@ namespace YooAsset.Editor if (CollectorType == ECollectorType.None) throw new Exception($"{nameof(ECollectorType)}.{ECollectorType.None} is invalid in collector : {CollectPath}"); - if (AssetBundleGrouperSettingData.HasPackRuleName(PackRuleName) == false) + if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false) throw new Exception($"Invalid {nameof(IPackRule)} class type : {PackRuleName} in collector : {CollectPath}"); - if (AssetBundleGrouperSettingData.HasFilterRuleName(FilterRuleName) == false) + if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false) throw new Exception($"Invalid {nameof(IFilterRule)} class type : {FilterRuleName} in collector : {CollectPath}"); - if (AssetBundleGrouperSettingData.HasAddressRuleName(AddressRuleName) == false) + if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false) throw new Exception($"Invalid {nameof(IAddressRule)} class type : {AddressRuleName} in collector : {CollectPath}"); } /// /// 获取打包收集的资源文件 /// - public List GetAllCollectAssets(AssetBundleGrouper grouper) + public List GetAllCollectAssets(AssetBundleCollectorGroup group) { Dictionary result = new Dictionary(1000); bool isRawAsset = PackRuleName == nameof(PackRawFile); @@ -97,7 +97,7 @@ namespace YooAsset.Editor throw new Exception($"The raw file must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}"); if (string.IsNullOrEmpty(CollectPath)) - throw new Exception($"The collect path is null or empty in grouper : {grouper.GrouperName}"); + throw new Exception($"The collect path is null or empty in group : {group.GroupName}"); // 收集打包资源 if (AssetDatabase.IsValidFolder(CollectPath)) @@ -110,7 +110,7 @@ namespace YooAsset.Editor { if (result.ContainsKey(assetPath) == false) { - var collectAssetInfo = CreateCollectAssetInfo(grouper, assetPath, isRawAsset); + var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset); result.Add(assetPath, collectAssetInfo); } else @@ -125,7 +125,7 @@ namespace YooAsset.Editor string assetPath = CollectPath; if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath)) { - var collectAssetInfo = CreateCollectAssetInfo(grouper, assetPath, isRawAsset); + var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset); result.Add(assetPath, collectAssetInfo); } else @@ -135,7 +135,7 @@ namespace YooAsset.Editor } // 检测可寻址地址是否重复 - if (AssetBundleGrouperSettingData.Setting.EnableAddressable) + if (AssetBundleCollectorSettingData.Setting.EnableAddressable) { HashSet adressTemper = new HashSet(); foreach (var collectInfoPair in result) @@ -155,11 +155,11 @@ namespace YooAsset.Editor return result.Values.ToList(); } - private CollectAssetInfo CreateCollectAssetInfo(AssetBundleGrouper grouper, string assetPath, bool isRawAsset) + private CollectAssetInfo CreateCollectAssetInfo(AssetBundleCollectorGroup group, string assetPath, bool isRawAsset) { - string address = GetAddress(grouper, assetPath); - string bundleName = GetBundleName(grouper, assetPath); - List assetTags = GetAssetTags(grouper); + string address = GetAddress(group, assetPath); + string bundleName = GetBundleName(group, assetPath); + List assetTags = GetAssetTags(group); CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset); collectAssetInfo.DependAssets = GetAllDependencies(assetPath); return collectAssetInfo; @@ -186,7 +186,7 @@ namespace YooAsset.Editor private bool IsCollectAsset(string assetPath) { // 如果收集全路径着色器 - if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders) + if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders) { Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath); if (assetType == typeof(UnityEngine.Shader)) @@ -194,41 +194,41 @@ namespace YooAsset.Editor } // 根据规则设置过滤资源文件 - IFilterRule filterRuleInstance = AssetBundleGrouperSettingData.GetFilterRuleInstance(FilterRuleName); + IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName); return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath)); } - private string GetAddress(AssetBundleGrouper grouper, string assetPath) + private string GetAddress(AssetBundleCollectorGroup group, string assetPath) { if (CollectorType != ECollectorType.MainAssetCollector) return string.Empty; - IAddressRule addressRuleInstance = AssetBundleGrouperSettingData.GetAddressRuleInstance(AddressRuleName); - string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, grouper.GrouperName)); + IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName); + string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName)); return adressValue; } - private string GetBundleName(AssetBundleGrouper grouper, string assetPath) + private string GetBundleName(AssetBundleCollectorGroup group, string assetPath) { // 如果自动收集所有的着色器 - if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders) + if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders) { System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath); if (assetType == typeof(UnityEngine.Shader)) { - string bundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName; + string bundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName; return EditorTools.GetRegularPath(bundleName).ToLower(); } } // 根据规则设置获取资源包名称 { - IPackRule packRuleInstance = AssetBundleGrouperSettingData.GetPackRuleInstance(PackRuleName); - string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, grouper.GrouperName)); + IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName); + string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName)); return EditorTools.GetRegularPath(bundleName).ToLower(); } } - private List GetAssetTags(AssetBundleGrouper grouper) + private List GetAssetTags(AssetBundleCollectorGroup group) { - List tags = StringUtility.StringToStringList(grouper.AssetTags, ';'); + List tags = StringUtility.StringToStringList(group.AssetTags, ';'); List temper = StringUtility.StringToStringList(AssetTags, ';'); tags.AddRange(temper); return tags; diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleCollector.cs.meta b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleCollector.cs.meta rename to Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperConfig.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs similarity index 68% rename from Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperConfig.cs rename to Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs index 80d3e3c..ea2edeb 100644 --- a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperConfig.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs @@ -8,14 +8,14 @@ using UnityEngine; namespace YooAsset.Editor { - public class AssetBundleGrouperConfig + public class AssetBundleCollectorConfig { public const string XmlShader = "Shader"; public const string XmlAutoCollectShader = "AutoCollectShader"; public const string XmlShaderBundleName = "ShaderBundleName"; - public const string XmlGrouper = "Grouper"; - public const string XmlGrouperName = "GrouperName"; - public const string XmlGrouperDesc = "GrouperDesc"; + public const string XmlGroup = "Group"; + public const string XmlGroupName = "GroupName"; + public const string XmlGroupDesc = "GroupDesc"; public const string XmlCollector = "Collector"; public const string XmlCollectPath = "CollectPath"; public const string XmlCollectorType = "CollectType"; @@ -57,26 +57,26 @@ namespace YooAsset.Editor } // 读取分组配置 - List grouperTemper = new List(); - var grouperNodeList = root.GetElementsByTagName(XmlGrouper); - foreach (var grouperNode in grouperNodeList) + List groupTemper = new List(); + var groupNodeList = root.GetElementsByTagName(XmlGroup); + foreach (var groupNode in groupNodeList) { - XmlElement grouperElement = grouperNode as XmlElement; - if (grouperElement.HasAttribute(XmlGrouperName) == false) - throw new Exception($"Not found attribute {XmlGrouperName} in {XmlGrouper}"); - if (grouperElement.HasAttribute(XmlGrouperDesc) == false) - throw new Exception($"Not found attribute {XmlGrouperDesc} in {XmlGrouper}"); - if (grouperElement.HasAttribute(XmlAssetTags) == false) - throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGrouper}"); + XmlElement groupElement = groupNode as XmlElement; + if (groupElement.HasAttribute(XmlGroupName) == false) + throw new Exception($"Not found attribute {XmlGroupName} in {XmlGroup}"); + if (groupElement.HasAttribute(XmlGroupDesc) == false) + throw new Exception($"Not found attribute {XmlGroupDesc} in {XmlGroup}"); + if (groupElement.HasAttribute(XmlAssetTags) == false) + throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGroup}"); - AssetBundleGrouper grouper = new AssetBundleGrouper(); - grouper.GrouperName = grouperElement.GetAttribute(XmlGrouperName); - grouper.GrouperDesc = grouperElement.GetAttribute(XmlGrouperDesc); - grouper.AssetTags = grouperElement.GetAttribute(XmlAssetTags); - grouperTemper.Add(grouper); + AssetBundleCollectorGroup group = new AssetBundleCollectorGroup(); + group.GroupName = groupElement.GetAttribute(XmlGroupName); + group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc); + group.AssetTags = groupElement.GetAttribute(XmlAssetTags); + groupTemper.Add(group); // 读取收集器配置 - var collectorNodeList = grouperElement.GetElementsByTagName(XmlCollector); + var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector); foreach (var collectorNode in collectorNodeList) { XmlElement collectorElement = collectorNode as XmlElement; @@ -100,16 +100,16 @@ namespace YooAsset.Editor collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule); collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule); collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags); ; - grouper.Collectors.Add(collector); + group.Collectors.Add(collector); } } // 保存配置数据 - AssetBundleGrouperSettingData.ClearAll(); - AssetBundleGrouperSettingData.Setting.AutoCollectShaders = autoCollectShaders; - AssetBundleGrouperSettingData.Setting.ShadersBundleName = shaderBundleName; - AssetBundleGrouperSettingData.Setting.Groupers.AddRange(grouperTemper); - AssetBundleGrouperSettingData.SaveFile(); + AssetBundleCollectorSettingData.ClearAll(); + AssetBundleCollectorSettingData.Setting.AutoCollectShaders = autoCollectShaders; + AssetBundleCollectorSettingData.Setting.ShadersBundleName = shaderBundleName; + AssetBundleCollectorSettingData.Setting.Groups.AddRange(groupTemper); + AssetBundleCollectorSettingData.SaveFile(); Debug.Log($"导入配置完毕!"); } @@ -132,20 +132,20 @@ namespace YooAsset.Editor // 设置着色器配置 var shaderElement = xmlDoc.CreateElement(XmlShader); - shaderElement.SetAttribute(XmlAutoCollectShader, AssetBundleGrouperSettingData.Setting.AutoCollectShaders.ToString()); - shaderElement.SetAttribute(XmlShaderBundleName, AssetBundleGrouperSettingData.Setting.ShadersBundleName); + shaderElement.SetAttribute(XmlAutoCollectShader, AssetBundleCollectorSettingData.Setting.AutoCollectShaders.ToString()); + shaderElement.SetAttribute(XmlShaderBundleName, AssetBundleCollectorSettingData.Setting.ShadersBundleName); // 设置分组配置 - foreach (var grouper in AssetBundleGrouperSettingData.Setting.Groupers) + foreach (var group in AssetBundleCollectorSettingData.Setting.Groups) { - var grouperElement = xmlDoc.CreateElement(XmlGrouper); - grouperElement.SetAttribute(XmlGrouperName, grouper.GrouperName); - grouperElement.SetAttribute(XmlGrouperDesc, grouper.GrouperDesc); - grouperElement.SetAttribute(XmlAssetTags, grouper.AssetTags); - root.AppendChild(grouperElement); + var groupElement = xmlDoc.CreateElement(XmlGroup); + groupElement.SetAttribute(XmlGroupName, group.GroupName); + groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc); + groupElement.SetAttribute(XmlAssetTags, group.AssetTags); + root.AppendChild(groupElement); // 设置收集器配置 - foreach (var collector in grouper.Collectors) + foreach (var collector in group.Collectors) { var collectorElement = xmlDoc.CreateElement(XmlCollector); collectorElement.SetAttribute(XmlCollectPath, collector.CollectPath); @@ -154,7 +154,7 @@ namespace YooAsset.Editor collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName); collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName); collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags); - grouperElement.AppendChild(collectorElement); + groupElement.AppendChild(collectorElement); } } diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperConfig.cs.meta b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperConfig.cs.meta rename to Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouper.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs similarity index 87% rename from Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouper.cs rename to Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs index 6f07d88..2fe9bb9 100644 --- a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouper.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs @@ -8,17 +8,17 @@ using UnityEditor; namespace YooAsset.Editor { [Serializable] - public class AssetBundleGrouper + public class AssetBundleCollectorGroup { /// /// 分组名称 /// - public string GrouperName = string.Empty; + public string GroupName = string.Empty; /// /// 分组描述 /// - public string GrouperDesc = string.Empty; + public string GroupDesc = string.Empty; /// /// 资源分类标签 @@ -58,12 +58,12 @@ namespace YooAsset.Editor if (result.ContainsKey(assetInfo.AssetPath) == false) result.Add(assetInfo.AssetPath, assetInfo); else - throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in grouper : {GrouperName}"); + throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group : {GroupName}"); } } // 检测可寻址地址是否重复 - if (AssetBundleGrouperSettingData.Setting.EnableAddressable) + if (AssetBundleCollectorSettingData.Setting.EnableAddressable) { HashSet adressTemper = new HashSet(); foreach (var collectInfoPair in result) @@ -74,7 +74,7 @@ namespace YooAsset.Editor if (adressTemper.Contains(address) == false) adressTemper.Add(address); else - throw new Exception($"The address is existed : {address} in grouper : {GrouperName}"); + throw new Exception($"The address is existed : {address} in group : {GroupName}"); } } } diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouper.cs.meta b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouper.cs.meta rename to Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperSetting.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs similarity index 82% rename from Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperSetting.cs rename to Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs index 449c5d7..65239d7 100644 --- a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperSetting.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs @@ -6,7 +6,7 @@ using UnityEngine; namespace YooAsset.Editor { - public class AssetBundleGrouperSetting : ScriptableObject + public class AssetBundleCollectorSetting : ScriptableObject { /// /// 是否启用可寻址资源定位 @@ -26,7 +26,7 @@ namespace YooAsset.Editor /// /// 分组列表 /// - public List Groupers = new List(); + public List Groups = new List(); /// @@ -34,9 +34,9 @@ namespace YooAsset.Editor /// public void CheckConfigError() { - foreach (var grouper in Groupers) + foreach (var group in Groups) { - grouper.CheckConfigError(); + group.CheckConfigError(); } } @@ -48,15 +48,15 @@ namespace YooAsset.Editor Dictionary result = new Dictionary(10000); // 收集打包资源 - foreach (var grouper in Groupers) + foreach (var group in Groups) { - var temper = grouper.GetAllCollectAssets(); + var temper = group.GetAllCollectAssets(); foreach (var assetInfo in temper) { if (result.ContainsKey(assetInfo.AssetPath) == false) result.Add(assetInfo.AssetPath, assetInfo); else - throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in grouper setting."); + throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group setting."); } } @@ -72,7 +72,7 @@ namespace YooAsset.Editor if (adressTemper.Contains(address) == false) adressTemper.Add(address); else - throw new Exception($"The address is existed : {address} in grouper setting."); + throw new Exception($"The address is existed : {address} in group setting."); } } } diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperSetting.cs.meta b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperSetting.cs.meta rename to Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperSettingData.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs similarity index 83% rename from Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperSettingData.cs rename to Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs index 9e32ca1..6b7707d 100644 --- a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperSettingData.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs @@ -7,7 +7,7 @@ using UnityEditor; namespace YooAsset.Editor { - public class AssetBundleGrouperSettingData + public class AssetBundleCollectorSettingData { private static readonly Dictionary _cacheAddressRuleTypes = new Dictionary(); private static readonly Dictionary _cacheAddressRuleInstance = new Dictionary(); @@ -24,8 +24,8 @@ namespace YooAsset.Editor public static bool IsDirty { private set; get; } = false; - private static AssetBundleGrouperSetting _setting = null; - public static AssetBundleGrouperSetting Setting + private static AssetBundleCollectorSetting _setting = null; + public static AssetBundleCollectorSetting Setting { get { @@ -106,12 +106,12 @@ namespace YooAsset.Editor private static void LoadSettingData() { // 加载配置文件 - string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleGrouperSetting)}.asset"; - _setting = AssetDatabase.LoadAssetAtPath(settingFilePath); + string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleCollectorSetting)}.asset"; + _setting = AssetDatabase.LoadAssetAtPath(settingFilePath); if (_setting == null) { - Debug.LogWarning($"Create new {nameof(AssetBundleGrouperSetting)}.asset : {settingFilePath}"); - _setting = ScriptableObject.CreateInstance(); + Debug.LogWarning($"Create new {nameof(AssetBundleCollectorSetting)}.asset : {settingFilePath}"); + _setting = ScriptableObject.CreateInstance(); EditorTools.CreateFileDirectory(settingFilePath); AssetDatabase.CreateAsset(Setting, settingFilePath); AssetDatabase.SaveAssets(); @@ -119,7 +119,7 @@ namespace YooAsset.Editor } else { - Debug.Log($"Load {nameof(AssetBundleGrouperSetting)}.asset ok"); + Debug.Log($"Load {nameof(AssetBundleCollectorSetting)}.asset ok"); } // IPackRule @@ -135,7 +135,7 @@ namespace YooAsset.Editor typeof(PackDirectory), typeof(PackTopDirectory), typeof(PackCollector), - typeof(PackGrouper), + typeof(PackGroup), typeof(PackRawFile), }; @@ -187,7 +187,7 @@ namespace YooAsset.Editor { typeof(AddressByFileName), typeof(AddressByCollectorAndFileName), - typeof(AddressByGrouperAndFileName) + typeof(AddressByGroupAndFileName) }; TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom(); @@ -212,7 +212,7 @@ namespace YooAsset.Editor IsDirty = false; EditorUtility.SetDirty(Setting); AssetDatabase.SaveAssets(); - Debug.Log($"{nameof(AssetBundleGrouperSetting)}.asset is saved!"); + Debug.Log($"{nameof(AssetBundleCollectorSetting)}.asset is saved!"); } } @@ -223,7 +223,7 @@ namespace YooAsset.Editor { Setting.AutoCollectShaders = false; Setting.ShadersBundleName = string.Empty; - Setting.Groupers.Clear(); + Setting.Groups.Clear(); SaveFile(); } @@ -296,43 +296,43 @@ namespace YooAsset.Editor } // 资源分组编辑相关 - public static void CreateGrouper(string grouperName) + public static void CreateGroup(string groupName) { - AssetBundleGrouper grouper = new AssetBundleGrouper(); - grouper.GrouperName = grouperName; - Setting.Groupers.Add(grouper); + AssetBundleCollectorGroup group = new AssetBundleCollectorGroup(); + group.GroupName = groupName; + Setting.Groups.Add(group); IsDirty = true; } - public static void RemoveGrouper(AssetBundleGrouper grouper) + public static void RemoveGroup(AssetBundleCollectorGroup group) { - if (Setting.Groupers.Remove(grouper)) + if (Setting.Groups.Remove(group)) { IsDirty = true; } else { - Debug.LogWarning($"Failed remove grouper : {grouper.GrouperName}"); + Debug.LogWarning($"Failed remove group : {group.GroupName}"); } } - public static void ModifyGrouper(AssetBundleGrouper grouper) + public static void ModifyGroup(AssetBundleCollectorGroup group) { - if (grouper != null) + if (group != null) { IsDirty = true; } } // 资源收集器编辑相关 - public static void CreateCollector(AssetBundleGrouper grouper, string collectPath) + public static void CreateCollector(AssetBundleCollectorGroup group, string collectPath) { AssetBundleCollector collector = new AssetBundleCollector(); collector.CollectPath = collectPath; - grouper.Collectors.Add(collector); + group.Collectors.Add(collector); IsDirty = true; } - public static void RemoveCollector(AssetBundleGrouper grouper, AssetBundleCollector collector) + public static void RemoveCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector) { - if (grouper.Collectors.Remove(collector)) + if (group.Collectors.Remove(collector)) { IsDirty = true; } @@ -341,9 +341,9 @@ namespace YooAsset.Editor Debug.LogWarning($"Failed remove collector : {collector.CollectPath}"); } } - public static void ModifyCollector(AssetBundleGrouper grouper, AssetBundleCollector collector) + public static void ModifyCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector) { - if (grouper != null && collector != null) + if (group != null && collector != null) { IsDirty = true; } diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperSettingData.cs.meta b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperSettingData.cs.meta rename to Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs similarity index 64% rename from Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperWindow.cs rename to Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs index 6526414..b7afdba 100644 --- a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleGrouperWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs @@ -9,12 +9,12 @@ using UnityEngine.UIElements; namespace YooAsset.Editor { - public class AssetBundleGrouperWindow : EditorWindow + public class AssetBundleCollectorWindow : EditorWindow { - [MenuItem("YooAsset/AssetBundle Grouper", false, 101)] + [MenuItem("YooAsset/AssetBundle Collector", false, 101)] public static void ShowExample() { - AssetBundleGrouperWindow window = GetWindow("资源包分组工具", true, EditorDefine.DockedWindowTypes); + AssetBundleCollectorWindow window = GetWindow("资源包收集工具", true, EditorDefine.DockedWindowTypes); window.minSize = new Vector2(800, 600); } @@ -22,15 +22,15 @@ namespace YooAsset.Editor private List _addressRuleList; private List _packRuleList; private List _filterRuleList; - private ListView _grouperListView; + private ListView _groupListView; private ScrollView _collectorScrollView; private Toggle _enableAddressableToogle; private Toggle _autoCollectShaderToogle; private TextField _shaderBundleNameTxt; - private TextField _grouperNameTxt; - private TextField _grouperDescTxt; - private TextField _grouperAssetTagsTxt; - private VisualElement _grouperContainer; + private TextField _groupNameTxt; + private TextField _groupDescTxt; + private TextField _groupAssetTagsTxt; + private VisualElement _groupContainer; public void CreateGUI() { @@ -45,17 +45,17 @@ namespace YooAsset.Editor $"{nameof(ECollectorType.StaticAssetCollector)}", $"{nameof(ECollectorType.DependAssetCollector)}" }; - _addressRuleList = AssetBundleGrouperSettingData.GetAddressRuleNames(); - _packRuleList = AssetBundleGrouperSettingData.GetPackRuleNames(); - _filterRuleList = AssetBundleGrouperSettingData.GetFilterRuleNames(); + _addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames(); + _packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames(); + _filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames(); // 加载布局文件 string rootPath = EditorTools.GetYooAssetSourcePath(); - string uxml = $"{rootPath}/Editor/AssetBundleGrouper/{nameof(AssetBundleGrouperWindow)}.uxml"; + string uxml = $"{rootPath}/Editor/AssetBundleCollector/{nameof(AssetBundleCollectorWindow)}.uxml"; var visualAsset = AssetDatabase.LoadAssetAtPath(uxml); if (visualAsset == null) { - Debug.LogError($"Not found {nameof(AssetBundleGrouperWindow)}.uxml : {uxml}"); + Debug.LogError($"Not found {nameof(AssetBundleCollectorWindow)}.uxml : {uxml}"); return; } visualAsset.CloneTree(root); @@ -72,75 +72,75 @@ namespace YooAsset.Editor _enableAddressableToogle = root.Q("EnableAddressable"); _enableAddressableToogle.RegisterValueChangedCallback(evt => { - AssetBundleGrouperSettingData.ModifyAddressable(evt.newValue); + AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue); }); _autoCollectShaderToogle = root.Q("AutoCollectShader"); _autoCollectShaderToogle.RegisterValueChangedCallback(evt => { - AssetBundleGrouperSettingData.ModifyShader(evt.newValue, _shaderBundleNameTxt.value); + AssetBundleCollectorSettingData.ModifyShader(evt.newValue, _shaderBundleNameTxt.value); _shaderBundleNameTxt.SetEnabled(evt.newValue); }); _shaderBundleNameTxt = root.Q("ShaderBundleName"); _shaderBundleNameTxt.RegisterValueChangedCallback(evt => { - AssetBundleGrouperSettingData.ModifyShader(_autoCollectShaderToogle.value, evt.newValue); + AssetBundleCollectorSettingData.ModifyShader(_autoCollectShaderToogle.value, evt.newValue); }); // 分组列表相关 - _grouperListView = root.Q("GrouperListView"); - _grouperListView.makeItem = MakeGrouperListViewItem; - _grouperListView.bindItem = BindGrouperListViewItem; + _groupListView = root.Q("GroupListView"); + _groupListView.makeItem = MakeGroupListViewItem; + _groupListView.bindItem = BindGroupListViewItem; #if UNITY_2020_1_OR_NEWER - _grouperListView.onSelectionChange += GrouperListView_onSelectionChange; + _groupListView.onSelectionChange += GroupListView_onSelectionChange; #else - _grouperListView.onSelectionChanged += GrouperListView_onSelectionChange; + _groupListView.onSelectionChanged += GroupListView_onSelectionChange; #endif // 分组添加删除按钮 - var grouperAddContainer = root.Q("GrouperAddContainer"); + var groupAddContainer = root.Q("GroupAddContainer"); { - var addBtn = grouperAddContainer.Q