I’m creating a plugin for the editor and one of the features is focus an specific asset inside the project tab.
I already found the path and the object with:
var path = AssetDatabase.GUIDToAssetPath(guid);
var obj = AssetDatabase.LoadMainAssetAtPath(path);
Now I’m trying to focus this “obj” in the project tab. To do that I tried:
Selection.activeObject = obj;
and
EditorGUIUtility.PingObject(obj);
It works, but when the folder where the asset is inside was collapsed, the user didn’t see the selection (like when you click on a script field inside the inspector).
My question is: is there some way to unfold all the container folders of an asset by script to make sure the user will see it?
After digging like crazy about this, I found the (unexpected) solution.
I simply closed and opened the Project Tab in every project that I have and everything started to work like magic! The assets are now being focused like expected, with all the parent folders being opened (including when I click on a script field in the inspector).