The documentation only identifies a couple of filters like ‘name:’ for names, ‘t:’ for type and ‘l:’ for labels. More exist, and are not documented. It would be useful to expose all of the actual control here rather than leaving much to user experimentation.
Line 20-27
// Supports the following syntax:
// ‘t:type’ syntax (e.g ‘t:Texture2D’ will show Texture2D objects)
// ‘l:assetlabel’ syntax (e.g ‘l:architecture’ will show assets with AssetLabel ‘architecture’)
// ‘ref[:id]:path’ syntax (e.g ‘ref:1234’ will show objects that references the object with instanceID 1234)
// ‘v:versionState’ syntax (e.g ‘v:modified’ will show objects that are modified locally)
// ‘s:softLockState’ syntax (e.g ‘s:inprogress’ will show objects that are modified by anyone (except you))
// ‘a:area’ syntax (e.g ‘a:all’ will s search in all assets, ‘a:assets’ will s search in assets folder only and ‘a:packages’ will s search in packages folder only)
// ‘glob:path’ syntax (e.g ‘glob:Assets/**/*.{png|PNG}’ will show objects in any subfolder with name ending by .png or .PNG)
Great find! Thanks for posting! Here’s a code block version of the comment:
// Supports the following syntax:
// 't:type' syntax (e.g 't:Texture2D' will show Texture2D objects)
// 'l:assetlabel' syntax (e.g 'l:architecture' will show assets with AssetLabel 'architecture')
// 'ref[:id]:path' syntax (e.g 'ref:1234' will show objects that references the object with instanceID 1234)
// 'v:versionState' syntax (e.g 'v:modified' will show objects that are modified locally)
// 's:softLockState' syntax (e.g 's:inprogress' will show objects that are modified by anyone (except you))
// 'a:area' syntax (e.g 'a:all' will s search in all assets, 'a:assets' will s search in assets folder only and 'a:packages' will s search in packages folder only)
// 'glob:path' syntax (e.g 'glob:Assets/**/*.{png|PNG}' will show objects in any subfolder with name ending by .png or .PNG)
so I want to find only assets in folder, is it possible?
Whats a problem?
// 'glob:path' syntax (e.g 'glob:Assets/**/*.{png|PNG}' will show objects in any subfolder with name ending by .png or .PNG)
var path = "Assets/SomeDir/SomeNextDir/Etc";
var filter = $"glob:{path}";
AssetDatabase.FindAssets(filter);
I would like to add that the filter “b:” also works (2023.1.9)
I don’t know if this was intentional but for me AssetDatabase.FindAssets("glob:*.ext"); did not work and need to add quote like this AssetDatabase.FindAssets("glob:\"*.ext\"");
Hey @LaneFox ,
I updated the API page with some more information: Unity - Scripting API: AssetDatabase.FindAssets
Its in the 2023.2 stream, but the information there should work with previous versions of the editor too.
Please let me know if there’s more you’d like to see in there.