mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-22 00:11:41 +00:00
perf #632
This commit is contained in:
@@ -159,8 +159,10 @@ namespace YooAsset.Editor
|
||||
List<string> findAssets = new List<string>();
|
||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||
{
|
||||
string collectDirectory = CollectPath;
|
||||
string[] findResult = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||
string findAssetType = filterRuleInstance.FindAssetType;
|
||||
string searchFolder = CollectPath;
|
||||
string[] findResult = EditorTools.FindAssets(findAssetType, searchFolder);
|
||||
findAssets.AddRange(findResult);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -23,7 +23,13 @@ namespace YooAsset.Editor
|
||||
public interface IFilterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否为收集资源
|
||||
/// 搜寻的资源类型
|
||||
/// 说明:使用引擎方法搜索获取所有资源列表
|
||||
/// </summary>
|
||||
string FindAssetType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证搜寻的资源是否为收集资源
|
||||
/// </summary>
|
||||
/// <returns>如果收集该资源返回TRUE</returns>
|
||||
bool IsCollectAsset(FilterRuleData data);
|
||||
|
||||
@@ -9,6 +9,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集所有资源")]
|
||||
public class CollectAll : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.All.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return true;
|
||||
@@ -18,6 +23,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集场景")]
|
||||
public class CollectScene : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.Scene.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
string extension = Path.GetExtension(data.AssetPath);
|
||||
@@ -28,6 +38,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集预制体")]
|
||||
public class CollectPrefab : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.Prefab.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".prefab";
|
||||
@@ -37,6 +52,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集精灵类型的纹理")]
|
||||
public class CollectSprite : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.Sprite.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath);
|
||||
@@ -58,6 +78,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集着色器")]
|
||||
public class CollectShader : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.Shader.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".shader";
|
||||
@@ -67,6 +92,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集着色器变种集合")]
|
||||
public class CollectShaderVariants : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.All.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".shadervariants";
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace YooAsset.Editor
|
||||
Shader,
|
||||
Sprite,
|
||||
Texture,
|
||||
RenderTexture,
|
||||
VideoClip,
|
||||
}
|
||||
|
||||
|
||||
@@ -169,6 +169,28 @@ namespace YooAsset.Editor
|
||||
/// <param name="searchInFolders">指定搜索的文件夹列表</param>
|
||||
/// <returns>返回搜集到的资源路径列表</returns>
|
||||
public static string[] FindAssets(EAssetSearchType searchType, string[] searchInFolders)
|
||||
{
|
||||
return FindAssets(searchType.ToString(), searchInFolders);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜集资源
|
||||
/// </summary>
|
||||
/// <param name="searchType">搜集的资源类型</param>
|
||||
/// <param name="searchInFolder">指定搜索的文件夹</param>
|
||||
/// <returns>返回搜集到的资源路径列表</returns>
|
||||
public static string[] FindAssets(EAssetSearchType searchType, string searchInFolder)
|
||||
{
|
||||
return FindAssets(searchType.ToString(), new string[] { searchInFolder });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜集资源
|
||||
/// </summary>
|
||||
/// <param name="searchType">搜集的资源类型</param>
|
||||
/// <param name="searchInFolders">指定搜索的文件夹列表</param>
|
||||
/// <returns>返回搜集到的资源路径列表</returns>
|
||||
public static string[] FindAssets(string searchType, string[] searchInFolders)
|
||||
{
|
||||
// 注意:AssetDatabase.FindAssets()不支持末尾带分隔符的文件夹路径
|
||||
for (int i = 0; i < searchInFolders.Length; i++)
|
||||
@@ -179,7 +201,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 注意:获取指定目录下的所有资源对象(包括子文件夹)
|
||||
string[] guids;
|
||||
if (searchType == EAssetSearchType.All)
|
||||
if (string.IsNullOrEmpty(searchType) || searchType == EAssetSearchType.All.ToString())
|
||||
guids = AssetDatabase.FindAssets(string.Empty, searchInFolders);
|
||||
else
|
||||
guids = AssetDatabase.FindAssets($"t:{searchType}", searchInFolders);
|
||||
@@ -206,7 +228,7 @@ namespace YooAsset.Editor
|
||||
/// <param name="searchType">搜集的资源类型</param>
|
||||
/// <param name="searchInFolder">指定搜索的文件夹</param>
|
||||
/// <returns>返回搜集到的资源路径列表</returns>
|
||||
public static string[] FindAssets(EAssetSearchType searchType, string searchInFolder)
|
||||
public static string[] FindAssets(string searchType, string searchInFolder)
|
||||
{
|
||||
return FindAssets(searchType, new string[] { searchInFolder });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user