/// <summary> /// Helper function to create a new search item for the current provider. /// </summary> /// <param name="id">Unique id of the search item. This is used to remove duplicates to the user view.</param> /// <param name="score">Score of the search item. The score is used to sort all the result per provider. Lower score are shown first.</param> /// <param name="label">The search item label is displayed on the first line of the search item UI widget.</param> /// <param name="description">The search item description is displayed on the second line of the search item UI widget.</param> /// <param name="thumbnail">The search item thumbnail is displayed left to the item label and description as a preview.</param> /// <param name="data">User data used to recover more information about a search item. Generally used in fetchLabel, fetchDescription, etc.</param> /// <returns>The newly created search item attached to the current search provider.</returns> public SearchItem CreateItem(string id, int score, string label, string description, Texture2D thumbnail, object data) { // If the user searched that item recently, // let give it a good score so it gets sorted first. if (SearchService.IsRecent(id)) { score = Math.Min(k_RecentUserScore, score); } #if false // Debug sorting description = $"DEBUG: id={id} - label={label} - description={description} - thumbnail={thumbnail} - data={data}"; label = $"{label ?? id} ({score})"; #endif return(new SearchItem(id) { score = score, label = label, description = description, descriptionFormat = SearchItemDescriptionFormat.Highlight | SearchItemDescriptionFormat.Ellipsis, thumbnail = thumbnail, provider = this, data = data }); }
/// <summary> /// Helper function to create a new search item for the current provider. /// </summary> /// <param name="id">Unique id of the search item. This is used to remove duplicates to the user view.</param> /// <param name="score">Score of the search item. The score is used to sort all the result per provider. Lower score are shown first.</param> /// <param name="label">The search item label is displayed on the first line of the search item UI widget.</param> /// <param name="description">The search item description is displayed on the second line of the search item UI widget.</param> /// <param name="thumbnail">The search item thumbnail is displayed left to the item label and description as a preview.</param> /// <param name="data">User data used to recover more information about a search item. Generally used in fetchLabel, fetchDescription, etc.</param> /// <returns>The newly created search item attached to the current search provider.</returns> public SearchItem CreateItem(string id, int score, string label, string description, Texture2D thumbnail, object data) { // If the user searched that item recently, // let give it a good score so it gets sorted first. if (SearchService.IsRecent(id)) { score = Math.Min(k_RecentUserScore, score); } return(new SearchItem(id) { score = score, label = label, description = description, descriptionFormat = SearchItemDescriptionFormat.Highlight | SearchItemDescriptionFormat.Ellipsis, thumbnail = thumbnail, provider = this, data = data }); }