Skip to content

Commit dd4c027

Browse files
committed
perf: improved asset item builder speed with large projects
1 parent fe7acec commit dd4c027

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

Editor/Builders/AssetsItemBuilder.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,13 @@ public AdvancedDropdownItem Build()
3131
AdvancedDropdownItem root = new AdvancedDropdownItem("Assets");
3232
splitToItem.Add("Assets/", root); // Needs the trailing slash to be recognized later on
3333

34-
TypeCache.TypeCollection types = TypeCache.GetTypesDerivedFrom(interfaceType);
35-
foreach (Type type in types)
34+
string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
35+
foreach (string assetPath in allAssetPaths)
3636
{
37-
if (type.IsAbstract || type.IsInterface) continue;
38-
if (!type.IsSubclassOf(typeof(Object))) continue;
39-
40-
IEnumerable<string> paths = AssetDatabase.FindAssets($"t:{type.Name}")
41-
.Select(AssetDatabase.GUIDToAssetPath);
42-
43-
foreach (string path in paths)
37+
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
38+
if (interfaceType.IsAssignableFrom(assetType))
4439
{
45-
CreateItemForPath(root, path);
40+
CreateItemForPath(root, assetPath);
4641
}
4742
}
4843

0 commit comments

Comments
 (0)