Resources.FindObjectsOfTypeAll() doesn't return all Textures

I have a project to which I've just added several hundred Textures, all of which are currently unreferenced --- they exist in the Project Assets folder, but are unreferenced in the Hierarchy, and unreferenced by any Materials.

If I make the following call:


...the list of Textures it provides doesn't include these new Textures.

I've noticed that if I select one of these new Textures in the editor so that I get a preview of it, that Texture then does show up in subsequent calls to `Resources.FindObjectsOfTypeAll` --- so I assume they're just not loaded into memory yet?

Is there a way I can preload all these unreferenced Textures, so I can get a complete list of Textures in the project?

Docs for Resources.FindObjectsOfTypeAll say "This function can return any type of Unity object that is loaded".

You could use System.IO.Directory.GetDirectories/GetFiles to iterate all the asset files under Application.dataPath, then apply AssetDatabase.LoadAssetAtPath to get the asset.

If you use the Project list and filter by type - like “t:Texture” or “t:Material” and then select and highlight all of those objects in the editor using SHIFT from the first to last, this loads them into memory in a way that Resources.FindObjectsOfTypeAll can find them. I wanted a script to find all audioclips and them add them into an existing object’s array in scene, so that I can automate having a list of all audioclips and this was the only reasonable method. If I put all my audioclips into one folder, then LoadAll() would work, but highlighting them all was by far the easiest solution and I can just put a Debug.Log note on the helper script that says it needs objects selected to work in the editor.

If you are using this method to do things in the editor - like building helper scripts that modify all objects of a certain type (sometimes we need to change a property of a script on all prefabs etc), find all project objects of a type that have a certain property value, like finding all materials using a shader by shader name, etc then you can use this method to enable it find the objects - just highlight whatever you need in the Project list and then run your tool menu script.

Objects in the current scene are always found by Resources.FindObjectsOfType so if you are just writing some helper script that searches through all loaded objects you can also just load each scene and run the same script in each scene.