Class TableEntrySearchData
Search item data when using a String Table or Asset Table search provider.
Namespace: UnityEditor.Localization.Search
Syntax
public class TableEntrySearchData
Examples
This shows how to extract the search data after performing a search for string and asset tables.
using System.Text;
using UnityEditor;
using UnityEditor.Localization.Search;
using UnityEditor.Search;
using UnityEngine;
public static class SearchSamples
{
static void PrintResults(ISearchList results)
{
var sb = new StringBuilder();
sb.AppendLine($"Found {results.Count} results:");
foreach (var r in results)
{
// Extract the search data
if (r.data is TableEntrySearchData tableData)
{
sb.AppendLine($"{tableData.Collection.TableCollectionName} - {tableData.Entry.Key}");
}
}
Debug.Log(sb.ToString());
}
/// <summary>
/// Find all entries which contain the text "hello" in English.
/// </summary>
[MenuItem("Localization Samples/Search/Find Hello")]
public static void FindHello()
{
var search = SearchService.Request("st: tr(en):hello", SearchFlags.Synchronous);
PrintResults(search);
}
/// <summary>
/// Find all entries which have an empty translated value
/// </summary>
[MenuItem("Localization Samples/Search/Find Empty")]
public static void FindEmpty()
{
var search = SearchService.Request("st: tr=\"\"", SearchFlags.Synchronous);
PrintResults(search);
}
/// <summary>
/// Find all entries which have a reference to the MyFlag.png file
/// </summary>
[MenuItem("Localization Samples/Search/Find Png File")]
public static void FindPngFile()
{
var search = SearchService.Request("at: tr=MyFlag.png", SearchFlags.Synchronous);
PrintResults(search);
}
/// <summary>
/// Find all entries which have an ItemGender metadata which contains a field or property called gender with the value Female.
/// </summary>
[MenuItem("Localization Samples/Search/Find Female Gender Items")]
public static void FindFemaleGenderItems()
{
var search = SearchService.Request("st: mt=ItemGender mv(gender)=Female", SearchFlags.Synchronous);
PrintResults(search);
}
}
Properties
Collection
The resulting StringTableCollection or AssetTableCollection for this search item.
Declaration
public LocalizationTableCollection Collection { get; }
Property Value
Type | Description |
---|---|
LocalizationTableCollection |
Entry
The resulting table entry for this search item.
Declaration
public SharedTableData.SharedTableEntry Entry { get; }
Property Value
Type | Description |
---|---|
SharedTableData.SharedTableEntry |