Hey there all (and @cirocontinisio ) ,
Now we have a big project and a big Assets Folder, and this is going to be bigger by the gem like contributions of all the people of community.
We have all Scriptable Objects (SOs) in the ScriptableObjects folder (arranged folderwise also inside). But new people who will come here may find to difficult to locate a specific SO, or its Type.
We have event system and many other other important systems based on SOs. If someone wants to find a specific SO to modify it, it would be time consuming and irritating to navigate through a large collection of SOs to find it (and it will increase with time).
So, I found a solution to tackle this problem. (Thread title says all, but)
I created an Editor window which finds all SOs in the Assets/Scriptable Objects folder and lists its types using a Popup. If user selects a type, window will list all SOs in project with that (selected) type, its name, and a locate button.
If locate button is pressed, the project window is focused, (in case any other window is focused on top of project window) and the SOs is pinged in yellow (as Unity does).
This way, we can locate all SOs of a specific type very quickly, and work on it.
Thanks,
Harsh
Here is some feedback for the PR… There are multiple AssetDatabase.FindAssets and AssetDatabase.LoadAsset calls that seem to get triggered over and over again during OnGUI. The tool would be more efficient when it builds the objectGUIDs, objects, SOTypes, etc data not every “frame”, but only when necessary. Otherwise when the project grows and ends up with more SOs, I’m afraid this can cause the editor to get slow.
Thanks for feedback,
one thing I could do is add in an another method which does all thing you said when window is opened and when a refresh all button is pressed.
Also, one question, is
GUILayout.Label()
call is also necessary each frame?
This sounds like a good change, thank you. Maybe the OnFocus event is interesting for this? So every time the window gets focused, it updates its content once.
Yes, the IMGUI methods need to be called each frame.
Cool, thanks for the update! I’ve pulled the PR, when I open Tools > Quick SO Access Tool, Unity outputs the following error every frame until I press the “Refresh All” button:
NullReferenceException: Object reference not set to an instance of an object
SOsQuickAccessToolWindow.DrawSOsList () (at Assets/Scripts/Editor/SOsQuickAccessToolWindow.cs:76)
SOsQuickAccessToolWindow.OnGUI () (at Assets/Scripts/Editor/SOsQuickAccessToolWindow.cs:59)
The reason for this is because displayObjectsGUIDs is null and only gets set when I press “Refresh All”.
Here is how you can reproduce it:
Close Quick SO Access Tool window
Reimport SOsQuickAccessToolWindow.cs
Click Tools > Quick SO Access Tool
Here are a few ideas from an UI point of view…
I think you can compact the UI quite a bit when you use EditorGUILayout.ObjectField in DrawSOsList to display each item, rather than Label+Button+Space. You also get the “Ping” for free that way.
I don’t think the help text “Please select Scriptable Object Type to search for” is necessary and would get back some precious UI space as well.
If you remove the label “Scriptable Object Types” and draw the “Popup” and “Refresh All” button on the same line, like a toolbar, would further compact the UI.
If the UI is very light, it allows the window to be docked somewhere all the time, without feeling like it steals some work-area.
Another thought would be to only have the Popup button and when you select a type, the tool inserts a search text in Unity’s Project window search field. You can use ProjectBrowser.SetSearch (requires Reflection) to insert a search text like t:MyScriptableObjectType.
Then you can get rid of the custom item list and re-use the Unity project window for that. What do you think?
Yes , I tried the approach earlier, but there is also a line that is focusing the project window.
The ObjectField will not Focus the project window if any other window (like Console) is focused.
Second Major problem I found when testing ObjectField was, it can be changed. (it’s reference)