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

(10886)

2D

(287)

Ads

(57)

AI & Navigation

(81)

Analytics

(130)

Animation

(406)

Asset Store

(364)

Asset Store Publisher

(19)

Assets

(551)

Audio

(185)

Cloud Build

(148)

Collaborate

(67)

Docs & Tutorials

(246)

Editor

(2545)

Everyplay

(17)

Game Performance Reporting

(21)

General

(987)

Graphics

(894)

GUI

(442)

Input

(173)

Licensing

(93)

Networking

(189)

Physics

(387)

Platforms

(445)

Profiling & Optimization

(84)

Runtime

(185)

Scripting

(1141)

Terrain

(174)

WebGL

(142)