To create a custom menu item that invokes a search, use the MenuItem attribute. The following example creates a menu item that searches the__ Asset Store__由 Unity 和社区成员创建的免费和付费的资产库,其规模处于不断壮大中。提供各种资产,涵盖了从纹理、模型和动画到完整项目示例、教程和编辑器扩展等类型。更多信息
See in Glossary for free assets:
[MenuItem("Search/Free Asset Gifts")]
static void SearchStore()
{
var storeContext = SearchService.CreateContext("store", "price=0");
var viewState = new SearchViewState(storeContext,
UnityEngine.Search.SearchViewFlags.DisableNoResultTips |
UnityEngine.Search.SearchViewFlags.GridView);
viewState.windowTitle = new GUIContent("Free Stuff for Christmas");
viewState.queryBuilderEnabled = true;
SearchService.ShowWindow(viewState);
}