feat : add IIgnoreRule interface
支持自定义过滤规则 移除了IgnoreDefaultType收集参数
This commit is contained in:
@@ -6,22 +6,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class DefaultFilterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 忽略的文件类型
|
||||
/// </summary>
|
||||
private readonly static HashSet<string> _ignoreFileExtensions = new HashSet<string>() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
||||
|
||||
/// <summary>
|
||||
/// 查询是否为忽略文件
|
||||
/// </summary>
|
||||
public static bool IsIgnoreFile(string fileExtension)
|
||||
{
|
||||
return _ignoreFileExtensions.Contains(fileExtension);
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("收集所有资源")]
|
||||
public class CollectAll : IFilterRule
|
||||
{
|
||||
@@ -69,7 +53,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[DisplayName("收集着色器")]
|
||||
public class CollectShader : IFilterRule
|
||||
{
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class DefaultIgnoreRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 忽略的文件类型
|
||||
/// </summary>
|
||||
public readonly static HashSet<string> IgnoreFileExtensions = new HashSet<string>() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 适配常规的资源构建管线
|
||||
/// </summary>
|
||||
public class NormalIgnoreRule : IIgnoreRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询是否为忽略文件
|
||||
/// </summary>
|
||||
public bool IsIgnore(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.AssetPath.StartsWith("Assets/") == false && assetInfo.AssetPath.StartsWith("Packages/") == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"Invalid asset path : {assetInfo.AssetPath}");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 忽略文件夹
|
||||
if (AssetDatabase.IsValidFolder(assetInfo.AssetPath))
|
||||
return true;
|
||||
|
||||
// 忽略编辑器下的类型资源
|
||||
if (assetInfo.AssetType == typeof(LightingDataAsset))
|
||||
return true;
|
||||
if (assetInfo.AssetType == typeof(LightmapParameters))
|
||||
return true;
|
||||
|
||||
// 忽略Unity引擎无法识别的文件
|
||||
if (assetInfo.AssetType == typeof(UnityEditor.DefaultAsset))
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetInfo.AssetPath}");
|
||||
return true;
|
||||
}
|
||||
|
||||
return DefaultIgnoreRule.IgnoreFileExtensions.Contains(assetInfo.FileExtension);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 适配原生文件构建管线
|
||||
/// </summary>
|
||||
public class RawFileIgnoreRule : IIgnoreRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询是否为忽略文件
|
||||
/// </summary>
|
||||
public bool IsIgnore(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.AssetPath.StartsWith("Assets/") == false && assetInfo.AssetPath.StartsWith("Packages/") == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"Invalid asset path : {assetInfo.AssetPath}");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 忽略文件夹
|
||||
if (AssetDatabase.IsValidFolder(assetInfo.AssetPath))
|
||||
return true;
|
||||
|
||||
// 忽略编辑器下的类型资源
|
||||
if (assetInfo.AssetType == typeof(LightingDataAsset))
|
||||
return true;
|
||||
if (assetInfo.AssetType == typeof(LightmapParameters))
|
||||
return true;
|
||||
|
||||
return DefaultIgnoreRule.IgnoreFileExtensions.Contains(assetInfo.FileExtension);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9c1900577194bb4ab49ce4332ccc4bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user