How to get enumerate all assets of a specific class?

I would like to somehow query the asset database to find all assets of a specific class (similar to what happens in EditorGUI.ObjectField). I would like an array of all assets that inherit the class SpecialScriptableObject.

Having spent a little time searching it seems that this data is stored in a Sqlite database that is stored in the “Library” folder. Is there an API that can be used to perform such a query efficiently?

Since Unity 4.5 it is now possible to achieve this using AssetDatabase.FindAssets:

foreach (string guid in AssetDatabase.FindAssets("t:SpecialScriptableObject")) {
    string assetPath = AssetDatabase.GUIDToAssetPath(guid);
    var asset = AssetDatabase.LoadAssetAtPath(assetPath, typeof(SpecialScriptableObject)) as SpecialScriptableObject;

    // Do whatever you want with the asset!

I have no access to the editor currently, but There are a few things you can check out:


Documentation: Unity - Scripting API: AssetDatabase.LoadAllAssetsAtPath

This returns an Object, you can query these objects to check whether they’re of a specific type (e.g: SpecialScriptableObject)

another option may be

Object.FindObjectsOfTypeIncludingAssets(Type type)

This static method looks for all assets of a certain type, although it will also look in the scene hierarchy.

You can see how to use this function in this similar question: How do you get a list of project scripts at edit-time? - Questions & Answers - Unity Discussions

I get out of memory exceptions when this gets run on a ~15gig project (and being 15 gigs is probably the problem), but I’ve never had issues dealing with a regular project. Should be a good starting point. For prefabs, the string extensions would be “prefab”; for images it might be “bmp”,“png”, and “tga”.

		string[] files = AssetDatabase.GetAllAssetPaths().Where(


			UnityEngine.Object thing = UnityEditor.AssetDatabase.LoadAssetAtPath(checkFile, typeof(T));
			T o = (T)thing;
			if ( null != o ) {
                           // hooray, O is an object of type T