searchText | 在搜索视图中显示的文本。 |
moveCursor | 在设置搜索文本后的光标位置。 |
设置搜索查询文本。
.
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"); } [MenuItem("Examples/ISearchView/SetSearchText_WithCursorPosition")] public static void SetSearchText_WithCursorPosition() { var view = SearchService.ShowContextual("asset"); view.SetSearchText("t:material", TextCursorPlacement.MoveLineStart); } }