Are project window searches scriptable?

Is there any way to script the Favorites section of the Project Window, or to filter the project window from a script? For example, could a script do the equivalent of typing ‘t:model house’ in the project window search field to show models with ‘house’ in the name?

Hi, I just stumbled across this question whilst trying to do almost exactly what you described in your example. I realise your question was asked some time ago so I won’t go into details on the solution I found unless anyone requests it:

    public void SetSearchString(string searchString)
    {
        Type projectBrowserType = Type.GetType("UnityEditor.ProjectBrowser,UnityEditor");
        EditorWindow window = GetWindow(projectBrowserType);
       
        // UnityEditor.ProjectBrowser.SetSearch(string searchString)
        MethodInfo setSearchMethodInfo = projectBrowserType.GetMethod("SetSearch", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance,
            null, new Type[] { typeof(string) }, null);

        setSearchMethodInfo.Invoke(window, new object[] { searchString });
    }

Full disclosure, I have received the odd error but it always seems to function in the small number of test situations I’ve tried.

I hope this helps someone :smiley: