Class SearchService | Package Manager UI website
docs.unity.cn
    Show / Hide Table of Contents

    Class SearchService

    Principal Quick Search API to initiate searches and fetch results.

    Inheritance
    System.Object
    SearchService
    Namespace: Unity.QuickSearch
    Syntax
    public static class SearchService

    Fields

    prefKey

    Declaration
    public const string prefKey = "quicksearch"
    Field Value
    Type Description
    System.String

    Properties

    Filter

    Returns the current search filter being applied.

    Declaration
    public static SearchFilter Filter { get; }
    Property Value
    Type Description
    SearchFilter

    OrderedProviders

    Returns the list of providers sorted by priority.

    Declaration
    public static IEnumerable<SearchProvider> OrderedProviders { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<SearchProvider>

    Providers

    Returns the list of all providers (active or not)

    Declaration
    public static List<SearchProvider> Providers { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<SearchProvider>

    Methods

    Disable(SearchContext)

    Indicates that a search session should be terminated.

    Declaration
    public static void Disable(SearchContext context)
    Parameters
    Type Name Description
    SearchContext context

    The search context ending the search session.

    Remarks

    Any asynchronously running search query will be stopped and all search result will be lost.

    Enable(SearchContext)

    Setup the search service before initiating a search session. A search session can be composed of many searches (different words, etc.)

    Declaration
    public static void Enable(SearchContext context)
    Parameters
    Type Name Description
    SearchContext context

    The search context to be initialized.

    GetAction(SearchProvider, String)

    Returns the search action data for a given provider and search action id.

    Declaration
    public static SearchAction GetAction(SearchProvider provider, string actionId)
    Parameters
    Type Name Description
    SearchProvider provider

    Provider to lookup

    System.String actionId

    Unique action ID within the provider.

    Returns
    Type Description
    SearchAction

    The matching action

    GetItems(SearchContext)

    Initiate a search and return all search items matching the search context. Other items can be found later using the asynchronous searches.

    Declaration
    public static List<SearchItem> GetItems(SearchContext context)
    Parameters
    Type Name Description
    SearchContext context

    The current search context

    Returns
    Type Description
    System.Collections.Generic.List<SearchItem>

    A list of search items matching the search query.

    GetKeywords(SearchContext, String)

    Returns a list of keywords used by auto-completion for the active providers.

    Declaration
    public static string[] GetKeywords(SearchContext context, string lastToken)
    Parameters
    Type Name Description
    SearchContext context

    Current search context

    System.String lastToken

    Search token currently being typed.

    Returns
    Type Description
    System.String[]

    A list of keywords that can be shown in an auto-complete dropdown.

    GetProvider(String)

    Returns the data of a search provider given its ID.

    Declaration
    public static SearchProvider GetProvider(string providerId)
    Parameters
    Type Name Description
    System.String providerId

    Unique ID of the provider

    Returns
    Type Description
    SearchProvider

    The matching provider

    IsRecent(String)

    Checks if a search item has been used recently.

    Declaration
    public static bool IsRecent(string id)
    Parameters
    Type Name Description
    System.String id

    Unique ID of the search item.

    Returns
    Type Description
    System.Boolean

    True if the item was used recently or false otherwise.

    Refresh()

    Clears everything and reloads all search providers.

    Declaration
    public static void Refresh()
    Remarks

    Use with care. Useful for unit tests.

    SetRecent(SearchItem)

    Sets the last activated search item.

    Declaration
    public static void SetRecent(SearchItem item)
    Parameters
    Type Name Description
    SearchItem item

    The item to be marked as been used recently.

    Events

    contentRefreshed

    Raised when the content of a search provider has changed.

    Declaration
    public static event Action<string[], string[], string[]> contentRefreshed
    Event Type
    Type Description
    System.Action<System.String[], System.String[], System.String[]>
    Back to top Copyright © 2019 Unity Technologies
    Generated by DocFX