Search Feedback

1
votes

Add EditorGUI.ToolbarSearchField API

Editor

-

-

The editor displays "Text Search Fields" in a lot places, such as in the Project and Hierarchy panel. However, no EditorGUI/EditorGUILayout SearchField API's have been exposed. Only UnityEditor.IMGUI.Controls contains a SearchField currently.

Please add EditorGUI.ToolbarSearchField and EditorGUI.DelayedToolbarSearchField.

Comments (1)

  1. 7814ee24455730d3307551815cd37ec0?d=mm

    Wanzyee

    Feb 11, 2018 16:48

    I'm not sure where is proper to post... you can take this currently... it's included in my editor utility script... LOL

    /// <summary>
    /// Make a toolbar style search field, optional to set a callback invoked when click the magnifier popup icon.
    /// </summary>
    /// <returns>The new text.</returns>
    /// <param name="text">The text to edit.</param>
    /// <param name="onPopup">The popup callback.</param>
    /// <param name="options">Layout options.</param>
    public static string SearchField(string text, Action onPopup = null, params GUILayoutOption[] options){

    var _position = new Rect(0f, 0f, 21f, EditorGUIUtility.singleLineHeight);
    EditorGUIUtility.AddCursorRect(_position, MouseCursor.Arrow);

    var _popup = (null != onPopup) && GUI.Button(_position, new GUIContent("", "Search..."), GUIStyle.none);
    var _style = (GUIStyle)((null == onPopup) ? "ToolbarSeachTextField" : "ToolbarSeachTextFieldPopup");

    var _options = new []{GUILayout.MaxWidth(285)};
    if(null != options) _options = _options.Concat(options).ToArray();

    GUILayout.BeginHorizontal();
    text = EditorGUILayout.TextField(text ?? "", _style, _options);

    var _cancel = GUILayout.Button("", "ToolbarSeachCancelButton");
    EditorGUILayout.Space();

    if(_popup || _cancel) GUI.FocusControl(null);
    if(_popup) onPopup.Invoke();

    GUILayout.EndHorizontal();
    return _cancel ? "" : text;

    }

Your opinion counts

Help us make things better. Share your great idea for improving Unity or vote for other people’s.

Log in to post a new idea

Categories

All

(9816)

2D

(259)

Ads

(49)

AI & Navigation

(77)

Analytics

(114)

Animation

(359)

Asset Store

(264)

Assets

(508)

Audio

(166)

Cloud Build

(119)

Collaborate

(44)

Docs & Tutorials

(216)

Editor

(2269)

Everyplay

(13)

Game Performance Reporting

(16)

General

(880)

Graphics

(814)

GUI

(394)

Input

(155)

Licensing

(82)

Networking

(174)

Physics

(361)

Platforms

(425)

Profiling & Optimization

(76)

Runtime

(168)

Scripting

(1087)

Terrain

(162)

WebGL

(138)