diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs index 3808c15..5f95fc5 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs @@ -40,11 +40,6 @@ namespace YooAsset.Editor /// public System.Type AssetType { private set; get; } - /// - /// 是否为着色器资源 - /// - public bool IsShaderAsset { private set; get; } - /// /// 资源的分类标签 /// @@ -66,10 +61,6 @@ namespace YooAsset.Editor AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath); AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath); - if (AssetType == typeof(UnityEngine.Shader) || AssetType == typeof(UnityEngine.ShaderVariantCollection)) - IsShaderAsset = true; - else - IsShaderAsset = false; } public BuildAssetInfo(string assetPath) { @@ -79,10 +70,6 @@ namespace YooAsset.Editor AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath); AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath); - if (AssetType == typeof(UnityEngine.Shader) || AssetType == typeof(UnityEngine.ShaderVariantCollection)) - IsShaderAsset = true; - else - IsShaderAsset = false; } diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs index 3ea00a1..94e3ba1 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs @@ -279,20 +279,21 @@ namespace YooAsset.Editor } private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath) { - System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath); - if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection)) + if (command.AutoCollectShaders) { - // 获取着色器打包规则结果 - PackRuleResult packRuleResult = DefaultPackRule.CreateShadersPackRuleResult(); - return packRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName); - } - else - { - // 获取其它资源打包规则结果 - IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName); - PackRuleResult packRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData)); - return packRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName); + System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath); + if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection)) + { + // 获取着色器打包规则结果 + PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult(); + return shaderPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName); + } } + + // 获取其它资源打包规则结果 + IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName); + PackRuleResult defaultPackRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData)); + return defaultPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName); } private List GetAssetTags(AssetBundleCollectorGroup group) { diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs index 0a7cc1b..9e9fb9b 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs @@ -40,6 +40,11 @@ namespace YooAsset.Editor /// public bool IgnoreDefaultType = true; + /// + /// 自动收集所有着色器(所有着色器存储在一个资源包内) + /// + public bool AutoCollectShaders = true; + /// /// 分组列表 /// diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs index 7031e42..57d36ef 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs @@ -101,7 +101,12 @@ namespace YooAsset.Editor // 创建资源收集命令 CollectCommand command = new CollectCommand(buildMode, packageName, - package.EnableAddressable, package.LocationToLower, package.IncludeAssetGUID, package.IgnoreDefaultType, UniqueBundleName); + package.EnableAddressable, + package.LocationToLower, + package.IncludeAssetGUID, + package.IgnoreDefaultType, + package.AutoCollectShaders, + UniqueBundleName); // 获取收集的资源集合 CollectResult collectResult = new CollectResult(command); diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs index 5e484af..88553a0 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs @@ -27,18 +27,20 @@ namespace YooAsset.Editor private VisualElement _helpBoxContainer; - private VisualElement _setting1Container; private Button _globalSettingsButton; + private Button _packageSettingsButton; + + private VisualElement _setting1Container; private Toggle _showPackageToogle; private Toggle _showEditorAliasToggle; private Toggle _uniqueBundleNameToogle; - private VisualElement _setting3Container; - private Button _packageSettingsButton; + private VisualElement _setting2Container; private Toggle _enableAddressableToogle; private Toggle _locationToLowerToogle; private Toggle _includeAssetGUIDToogle; private Toggle _ignoreDefaultTypeToogle; + private Toggle _autoCollectShadersToogle; private VisualElement _packageContainer; private ListView _packageListView; @@ -91,10 +93,13 @@ namespace YooAsset.Editor // 警示栏 _helpBoxContainer = root.Q("HelpBoxContainer"); - // 公共设置相关 - _setting1Container = root.Q("PublicContainer1"); _globalSettingsButton = root.Q