From 66cd49149304e8c52a5987b340329578959c3092 Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 21 Dec 2022 12:04:56 +0800 Subject: [PATCH] update editor code --- .../Editor/AssetBundleBuilder/BuildAssetInfo.cs | 7 +++++-- .../AssetBundleBuilder/EOutputNameStyle.cs | 10 +++++----- .../AssetBundleCollector.cs | 5 ++++- .../AssetBundleCollector/DefaultPackRule.cs | 17 ++++++----------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs index ec364a4..71f63da 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs @@ -184,8 +184,11 @@ namespace YooAsset.Editor { IPackRule packRule = PackDirectory.StaticPackRule; var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath)); - var shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}"; - _shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower(); + if (YooAssetSettingsData.Setting.RegularBundleName) + bundleName = EditorTools.GetRegularPath(bundleName).Replace('/', '_').Replace('.', '_').ToLower(); + else + bundleName = EditorTools.GetRegularPath(bundleName).ToLower(); + _shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}"; } } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/EOutputNameStyle.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/EOutputNameStyle.cs index 6cde3ff..8f9d11c 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/EOutputNameStyle.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/EOutputNameStyle.cs @@ -7,18 +7,18 @@ namespace YooAsset.Editor public enum EOutputNameStyle { /// - /// 000000000000000f000000000000000 + /// 哈希值名称 /// HashName = 1, /// - /// 000000000000000f000000000000000.bundle + /// 资源包名称 /// - HashName_Extension = 2, + BundleName = 2, /// - /// 000000000000000f000000000000000_bundle_name.bundle + /// 资源包名称 + 哈希值名称 /// - HashName_BundleName_Extension = 4, + BundleName_HashName = 4, } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs index ece39f6..8449b7c 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs @@ -293,7 +293,10 @@ namespace YooAsset.Editor // 根据规则设置获取资源包名称 IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName); string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName)); - return EditorTools.GetRegularPath(bundleName).ToLower(); + if(YooAssetSettingsData.Setting.RegularBundleName) + return EditorTools.GetRegularPath(bundleName).Replace('/', '_').Replace('.', '_').ToLower(); + else + return EditorTools.GetRegularPath(bundleName).ToLower(); } private List GetAssetTags(AssetBundleCollectorGroup group) { diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs index 0304a27..3dbc7c9 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs @@ -15,8 +15,7 @@ namespace YooAsset.Editor { string IPackRule.GetBundleName(PackRuleData data) { - string bundleName = StringUtility.RemoveExtension(data.AssetPath); - return EditorTools.GetRegularPath(bundleName).Replace('/', '_'); + return StringUtility.RemoveExtension(data.AssetPath); } } @@ -33,8 +32,7 @@ namespace YooAsset.Editor string IPackRule.GetBundleName(PackRuleData data) { - string bundleName = Path.GetDirectoryName(data.AssetPath); - return EditorTools.GetRegularPath(bundleName).Replace('/', '_'); + return Path.GetDirectoryName(data.AssetPath); } } @@ -58,7 +56,7 @@ namespace YooAsset.Editor if (Path.HasExtension(splits[0])) throw new Exception($"Not found root directory : {assetPath}"); string bundleName = $"{data.CollectPath}/{splits[0]}"; - return EditorTools.GetRegularPath(bundleName).Replace('/', '_'); + return bundleName; } else { @@ -79,13 +77,11 @@ namespace YooAsset.Editor string collectPath = data.CollectPath; if (AssetDatabase.IsValidFolder(collectPath)) { - string bundleName = collectPath; - return EditorTools.GetRegularPath(bundleName).Replace('/', '_'); + return collectPath; } else { - string bundleName = StringUtility.RemoveExtension(collectPath); - return EditorTools.GetRegularPath(bundleName).Replace('/', '_'); + return StringUtility.RemoveExtension(collectPath); } } } @@ -126,8 +122,7 @@ namespace YooAsset.Editor if (depends.Length != 1) throw new Exception($"{nameof(PackRawFile)} is not support estension : {extension}"); - string bundleName = data.AssetPath; - return EditorTools.GetRegularPath(bundleName).Replace('/', '_').Replace('.', '_'); + return data.AssetPath; } }