Update AssetBundleGrouper

pull/4/head
hevinci 2022-04-03 13:00:45 +08:00
parent 4894e06df3
commit f711d7eca1
4 changed files with 20 additions and 14 deletions

View File

@ -40,7 +40,7 @@ namespace YooAsset.Editor
/// </summary>
public void CheckConfigError()
{
if(AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(CollectPath) == null)
if (AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(CollectPath) == null)
throw new Exception($"Invalid collect path : {CollectPath}");
if (AssetBundleGrouperSettingData.HasPackRuleName(PackRuleName) == false)
@ -137,7 +137,7 @@ namespace YooAsset.Editor
// 根据规则设置过滤资源文件
IFilterRule filterRuleInstance = AssetBundleGrouperSettingData.GetFilterRuleInstance(FilterRuleName);
return filterRuleInstance.IsCollectAsset(assetPath);
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath));
}
private string GetBundleName(AssetBundleGrouper grouper, string assetPath)
{

View File

@ -9,7 +9,7 @@ namespace YooAsset.Editor
/// </summary>
public class CollectAll : IFilterRule
{
public bool IsCollectAsset(string assetPath)
public bool IsCollectAsset(FilterRuleData data)
{
return true;
}
@ -20,9 +20,9 @@ namespace YooAsset.Editor
/// </summary>
public class CollectScene : IFilterRule
{
public bool IsCollectAsset(string assetPath)
public bool IsCollectAsset(FilterRuleData data)
{
return Path.GetExtension(assetPath) == ".unity";
return Path.GetExtension(data.AssetPath) == ".unity";
}
}
@ -31,9 +31,9 @@ namespace YooAsset.Editor
/// </summary>
public class CollectPrefab : IFilterRule
{
public bool IsCollectAsset(string assetPath)
public bool IsCollectAsset(FilterRuleData data)
{
return Path.GetExtension(assetPath) == ".prefab";
return Path.GetExtension(data.AssetPath) == ".prefab";
}
}
@ -42,9 +42,9 @@ namespace YooAsset.Editor
/// </summary>
public class CollectSprite : IFilterRule
{
public bool IsCollectAsset(string assetPath)
public bool IsCollectAsset(FilterRuleData data)
{
if (AssetDatabase.GetMainAssetTypeAtPath(assetPath) == typeof(Sprite))
if (AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath) == typeof(Sprite))
return true;
else
return false;

View File

@ -1,6 +1,16 @@

namespace YooAsset.Editor
{
public struct FilterRuleData
{
public string AssetPath;
public FilterRuleData(string assetPath)
{
AssetPath = assetPath;
}
}
/// <summary>
/// 资源过滤规则接口
/// </summary>
@ -9,8 +19,7 @@ namespace YooAsset.Editor
/// <summary>
/// 是否为收集资源
/// </summary>
/// <param name="assetPath">资源路径</param>
/// <returns>如果收集该资源返回TRUE</returns>
bool IsCollectAsset(string assetPath);
bool IsCollectAsset(FilterRuleData data);
}
}

View File

@ -1,9 +1,6 @@

namespace YooAsset.Editor
{
/// <summary>
/// 打包规则数据
/// </summary>
public struct PackRuleData
{
public string AssetPath;