- Home /
Custom Editor Search bar
Hi,
Is there a way to integrate the same search bar that is in the project or hierarchy view in a custom window with the same style.
Thanks.
Answer by MaT227 · May 30, 2013 at 06:33 AM
I grabbed the Editor GUISkin like this to have the GUIStyle list and used it like this :
EditorGUIUtility.LookLikeInspector();
GUILayout.BeginHorizontal(GUI.skin.FindStyle("Toolbar"));
GUILayout.FlexibleSpace();
searchString = GUILayout.TextField(searchString, GUI.skin.FindStyle("ToolbarSeachTextField"));
if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton")))
{
// Remove focus if cleared
searchString = "";
GUI.FocusControl(null);
}
GUILayout.EndHorizontal();
But it could break in the futur.
btw1: Is there a link were all the editor styles are referenced ? I used a small trick to look at them, it could be cool to have all the built-in skins.
Just want to add that a list of all built in resource styles can be seen with previews using this script. It's useful!
In case you (you reading this comment) didn't notice, both ToolbarSeachTextField and ToolbarSeachCancelButton have "Search" spelled wrong. If Unity fixes this internally in the future, our FindStyle calls will have to be changed too. :(
Answer by Matt(Trip)Maker · Jun 04, 2013 at 08:11 PM
Just as a note -- I see that there's an EditorStyles class, but the search bar styles are private :-( http://docs.unity3d.com/Documentation/ScriptReference/EditorStyles.html
Yes :( That's why I copied the class in a GUISkin and looked at the Custom Style. Next, I can use it with
EditorGUIUtility.LookLikeInspector();
GUI.skin.FindStyle("style");