using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace YooAsset.Editor
{
public class DefaultIgnoreRule
{
///
/// 忽略的文件类型
///
public readonly static HashSet IgnoreFileExtensions = new HashSet() { "", ".so", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
}
///
/// 适配常规的资源构建管线
///
public class NormalIgnoreRule : IIgnoreRule
{
///
/// 查询是否为忽略文件
///
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.AssetPath.Contains("/Gizmos/"))
return true;
// 忽略编辑器专属资源
if (assetInfo.AssetPath.Contains("/Editor/") || assetInfo.AssetPath.Contains("/Editor Resources/"))
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);
}
}
///
/// 适配原生文件构建管线
///
public class RawFileIgnoreRule : IIgnoreRule
{
///
/// 查询是否为忽略文件
///
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);
}
}
}