SetSearchText
Sets the search query text.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Method
- Namespace: UnityEditor.Search
- Assembly: UnityEditor
SetSearchText(string, TextCursorPlacement)
Sets the search query text.
void SetSearchText(string searchText, TextCursorPlacement moveCursor = TextCursorPlacement.Default)
Parameters
Text displayed in the search view.
Position of the cursor after setting the search text.
Remarks


.
Examples
using UnityEngine;using UnityEditor;using UnityEditor.Search;static class Example_ISearchView_SetSearchText{ [MenuItem("Examples/ISearchView/SetSearchText")] public static void SetInitialText() { var view = SearchService.ShowContextual("asset"); // Set the initial text of Search view. By default the whole text of the search query will be selected. view.SetSearchText("t:prefab"); Debug.Assert(view.context.searchText == "t:prefab"); } #region SetSearchText_WithCursorPosition [MenuItem("Examples/ISearchView/SetSearchText_WithCursorPosition")] public static void SetSearchText_WithCursorPosition() { var view = SearchService.ShowContextual("asset"); view.SetSearchText("t:material", TextCursorPlacement.MoveLineStart); } #endregion}
SetSearchText(string, TextCursorPlacement, int)
Sets the search query text.
void SetSearchText(string searchText, TextCursorPlacement moveCursor, int cursorInsertPosition)
Parameters
Text displayed in the search view.
Position of the cursor after setting the search text.
Remarks


.
Examples
using UnityEngine;using UnityEditor;using UnityEditor.Search;static class Example_ISearchView_SetSearchText{ [MenuItem("Examples/ISearchView/SetSearchText")] public static void SetInitialText() { var view = SearchService.ShowContextual("asset"); // Set the initial text of Search view. By default the whole text of the search query will be selected. view.SetSearchText("t:prefab"); Debug.Assert(view.context.searchText == "t:prefab"); } #region SetSearchText_WithCursorPosition [MenuItem("Examples/ISearchView/SetSearchText_WithCursorPosition")] public static void SetSearchText_WithCursorPosition() { var view = SearchService.ShowContextual("asset"); view.SetSearchText("t:material", TextCursorPlacement.MoveLineStart); } #endregion}