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

    Class SearchProvider

    SearchProvider manages search for specific type of items and manages thumbnails, description and subfilters, etc.

    Inheritance
    System.Object
    SearchProvider
    Namespace: Unity.QuickSearch
    Syntax
    public class SearchProvider

    Constructors

    SearchProvider(String, String)

    Declaration
    public SearchProvider(string id, string displayName = null)
    Parameters
    Type Name Description
    System.String id
    System.String displayName

    Fields

    active

    Indicates if the provider is active or not. Inactive providers are completely ignored by the search service. The active state can be toggled in the search settings.

    Declaration
    public bool active
    Field Value
    Type Description
    System.Boolean

    fetchDescription

    Handler to provider an async description for an item. Will be called when the item is about to be displayed. Allows a plugin provider to only fetch long description when they are needed.

    Declaration
    public FetchStringHandler fetchDescription
    Field Value
    Type Description
    FetchStringHandler

    fetchItems

    MANDATORY: Handler to get items for a given search context.

    Declaration
    public GetItemsHandler fetchItems
    Field Value
    Type Description
    GetItemsHandler

    fetchKeywords

    Provider can return a list of words that will help the user complete his search query

    Declaration
    public GetKeywordsHandler fetchKeywords
    Field Value
    Type Description
    GetKeywordsHandler

    fetchLabel

    Handler used to fetch and format the label of a search item.

    Declaration
    public FetchStringHandler fetchLabel
    Field Value
    Type Description
    FetchStringHandler

    fetchPreview

    Similar to fetchThumbnail, fetchPreview usually returns a bigger preview. The QuickSearch UI will progressively show one preview each frame, preventing the UI to block if many preview needs to be generated at the same time.

    Declaration
    public PreviewHandler fetchPreview
    Field Value
    Type Description
    PreviewHandler

    fetchThumbnail

    Handler to provider an async thumbnail for an item. Will be called when the item is about to be displayed. Compared to preview a thumbnail should be small and returned as fast as possible. Use fetchPreview if you want to generate a preview that is bigger and slower to return. Allows a plugin provider to only fetch/generate preview when they are needed.

    Declaration
    public ThumbnailHandler fetchThumbnail
    Field Value
    Type Description
    ThumbnailHandler

    filterId

    Text token use to "filter" a provider (ex: "me:", "p:", "s:")

    Declaration
    public string filterId
    Field Value
    Type Description
    System.String

    isEnabledForContextualSearch

    Called when quicksearch is invoked in "contextual mode". If you return true it means the provider is enabled for this search context.

    Declaration
    public IsEnabledForContextualSearch isEnabledForContextualSearch
    Field Value
    Type Description
    IsEnabledForContextualSearch

    isExplicitProvider

    This provider is only active when specified explicitly using his filterId

    Declaration
    public bool isExplicitProvider
    Field Value
    Type Description
    System.Boolean

    name

    Unique id of the provider.

    Declaration
    public NameId name
    Field Value
    Type Description
    NameId

    onDisable

    Called when the QuickSearchWindow is closed. Allow the Provider to release cached resources.

    Declaration
    public Action onDisable
    Field Value
    Type Description
    System.Action

    onEnable

    Called when the QuickSearchWindow is opened. Allow the Provider to perform some caching.

    Declaration
    public Action onEnable
    Field Value
    Type Description
    System.Action

    priority

    Hint to sort the Provider. Affect the order of search results and the order in which provider are shown in the FilterWindow.

    Declaration
    public int priority
    Field Value
    Type Description
    System.Int32

    startDrag

    If implemented, it means the item supports drag. It is up to the SearchProvider to properly setup the DragAndDrop manager.

    Declaration
    public StartDragHandler startDrag
    Field Value
    Type Description
    StartDragHandler

    subCategories

    List of subfilters that will be visible in the FilterWindow for a given SearchProvider (see AssetProvider for an example).

    Declaration
    public List<NameId> subCategories
    Field Value
    Type Description
    System.Collections.Generic.List<NameId>

    trackSelection

    Called when the selection changed and can be tracked.

    Declaration
    public TrackSelectionHandler trackSelection
    Field Value
    Type Description
    TrackSelectionHandler

    Properties

    avgTime

    Declaration
    public double avgTime { get; }
    Property Value
    Type Description
    System.Double

    Methods

    CreateItem(String, Int32, String, String, Texture2D, Object)

    Helper function to create a new search item for the current provider.

    Declaration
    public SearchItem CreateItem(string id, int score, string label, string description, Texture2D thumbnail, object data)
    Parameters
    Type Name Description
    System.String id

    Unique id of the search item. This is used to remove duplicates to the user view.

    System.Int32 score

    Score of the search item. The score is used to sort all the result per provider. Lower score are shown first.

    System.String label

    The search item label is displayed on the first line of the search item UI widget.

    System.String description

    The search item description is displayed on the second line of the search item UI widget.

    Texture2D thumbnail

    The search item thumbnail is displayed left to the item label and description as a preview.

    System.Object data

    User data used to recover more information about a search item. Generally used in fetchLabel, fetchDescription, etc.

    Returns
    Type Description
    SearchItem

    The newly created search item attached to the current search provider.

    CreateItem(String, String, String, Texture2D, Object)

    Declaration
    public SearchItem CreateItem(string id, string label = null, string description = null, Texture2D thumbnail = null, object data = null)
    Parameters
    Type Name Description
    System.String id
    System.String label
    System.String description
    Texture2D thumbnail
    System.Object data
    Returns
    Type Description
    SearchItem

    MatchSearchGroups(SearchContext, String, Boolean)

    Declaration
    public static bool MatchSearchGroups(SearchContext context, string content, bool useLowerTokens = false)
    Parameters
    Type Name Description
    SearchContext context
    System.String content
    System.Boolean useLowerTokens
    Returns
    Type Description
    System.Boolean

    RecordFetchTime(Double)

    Declaration
    public void RecordFetchTime(double t)
    Parameters
    Type Name Description
    System.Double t
    Back to top Copyright © 2019 Unity Technologies
    Generated by DocFX