Class SearchItem
Search items are returned by the search provider when some results need to be shown to the user after a search is made. The search item holds all the data that will be used to sort and present the search results.
Namespace: Unity.QuickSearch
Syntax
public class SearchItem : IEquatable<SearchItem>, IComparable<SearchItem>Constructors
SearchItem(String)
Construct a search item. Minimally a search item need to have a unique id for a given search query.
Declaration
public SearchItem(string _id)Parameters
| Type | Name | Description | 
|---|---|---|
| String | _id | 
Fields
context
Context used to create that item.
Declaration
public SearchContext contextField Value
| Type | Description | 
|---|---|
| SearchContext | 
data
Search provider defined content. It can be used to transport any data to custom search provider handlers (i.e. fetchDescription).
Declaration
public object dataField Value
| Type | Description | 
|---|---|
| Object | 
description
If no description is provided, SearchProvider.fetchDescription will be called when the item is first displayed.
Declaration
public string descriptionField Value
| Type | Description | 
|---|---|
| String | 
id
Unique id of this item among this provider items.
Declaration
public readonly string idField Value
| Type | Description | 
|---|---|
| String | 
label
Display name of the item
Declaration
public string labelField Value
| Type | Description | 
|---|---|
| String | 
none
A search item representing none, usually used to clear the selection.
Declaration
public static readonly SearchItem noneField Value
| Type | Description | 
|---|---|
| SearchItem | 
options
Various flags that dictates how the search item is displayed and used.
Declaration
public SearchItemOptions optionsField Value
| Type | Description | 
|---|---|
| SearchItemOptions | 
preview
Large preview of the search item. Usually cached by fetchPreview.
Declaration
public Texture2D previewField Value
| Type | Description | 
|---|---|
| Texture2D | 
provider
Back pointer to the provider.
Declaration
public SearchProvider providerField Value
| Type | Description | 
|---|---|
| SearchProvider | 
score
The item score can affect how the item gets sorted within the same provider.
Declaration
public int scoreField Value
| Type | Description | 
|---|---|
| Int32 | 
thumbnail
If no thumbnail are provider, SearchProvider.fetchThumbnail will be called when the item is first displayed.
Declaration
public Texture2D thumbnailField Value
| Type | Description | 
|---|---|
| Texture2D | 
Methods
Compare(SearchItem, SearchItem)
Check if 2 SearchItems have the same id.
Declaration
public int Compare(SearchItem x, SearchItem y)Parameters
| Type | Name | Description | 
|---|---|---|
| SearchItem | x | |
| SearchItem | y | 
Returns
| Type | Description | 
|---|---|
| Int32 | Returns true if SearchItem have the same id. | 
CompareTo(SearchItem)
Check if 2 SearchItems have the same id.
Declaration
public int CompareTo(SearchItem other)Parameters
| Type | Name | Description | 
|---|---|---|
| SearchItem | other | 
Returns
| Type | Description | 
|---|---|
| Int32 | Returns true if SearchItem have the same id. | 
Equals(Object)
Check if 2 SearchItems have the same id.
Declaration
public override bool Equals(object other)Parameters
| Type | Name | Description | 
|---|---|---|
| Object | other | 
Returns
| Type | Description | 
|---|---|
| Boolean | 
 | 
Overrides
Equals(SearchItem)
Check if 2 SearchItems have the same id.
Declaration
public bool Equals(SearchItem other)Parameters
| Type | Name | Description | 
|---|---|---|
| SearchItem | other | 
Returns
| Type | Description | 
|---|---|
| Boolean | 
 | 
GetDescription(SearchContext, Boolean)
Fetch and format description
Declaration
public string GetDescription(SearchContext context, bool stripHTML = false)Parameters
| Type | Name | Description | 
|---|---|---|
| SearchContext | context | Any search context for the item provider. | 
| Boolean | stripHTML | True if any HTML tags should be dropped. | 
Returns
| Type | Description | 
|---|---|
| String | The search item description | 
GetHashCode()
Default Hash of a SearchItem
Declaration
public override int GetHashCode()Returns
| Type | Description | 
|---|---|
| Int32 | A hash code for the current SearchItem | 
Overrides
GetLabel(SearchContext, Boolean)
Fetch and format label.
Declaration
public string GetLabel(SearchContext context, bool stripHTML = false)Parameters
| Type | Name | Description | 
|---|---|---|
| SearchContext | context | Any search context for the item provider. | 
| Boolean | stripHTML | True if any HTML tags should be dropped. | 
Returns
| Type | Description | 
|---|---|
| String | The search item label |