- Home /
How to Load/Unload assets in Editor?
I'm using Resources.FindObjectsOfTypeAll to collect all instances of a script to expose them in a custom tool. The help for this function states that it finds all "loaded" objects of that type. It seem like the user can load a prefab by clicking on it, and then FindObjectsOfTypeAll will see it. However, I'm looking for some programmatic way to load/unload these scripts. More specifically:
A way to load all prefabs that use the script.
A way to unload prefabs at will (e.g., if they're not used by the current scene).
For the latter, I've tried UnloadUnusedAssetsIgnoreManagedReferences and it unloads all loaded prefabs, but plays havoc with other resources I'm using in the tool.
For the former, Joachim had this advice: Check out HierarchyProperty in assetdatabase mode. This is how we implement search.
But I can't find a HierarchyProperty in any AssetDatabase methods.