docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class TableEntrySearchData

    Search item data when using a String Table or Asset Table search provider.

    Inheritance
    object
    TableEntrySearchData
    Namespace: UnityEditor.Localization.Search
    Assembly: Unity.Localization.Editor.dll
    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

    Name Description
    Collection

    The resulting StringTableCollection or AssetTableCollection for this search item.

    Entry

    The resulting table entry for this search item.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)