docs.unity3d.com
    Show / Hide Table of Contents

    Class StringTableCollection

    Provides methods for managing multiple StringTable in the Editor.

    Inheritance
    Object
    Object
    ScriptableObject
    LocalizationTableCollection
    StringTableCollection
    Inherited Members
    LocalizationTableCollection.Tables
    LocalizationTableCollection.Extensions
    LocalizationTableCollection.TableCollectionName
    LocalizationTableCollection.TableCollectionNameReference
    LocalizationTableCollection.SharedData
    LocalizationTableCollection.Group
    LocalizationTableCollection.SetTableCollectionName(String, Boolean)
    LocalizationTableCollection.SetPreloadTableFlag(Boolean, Boolean)
    LocalizationTableCollection.IsPreloadTableFlagSet()
    LocalizationTableCollection.AddTable(LocalizationTable, Boolean, Boolean)
    LocalizationTableCollection.AddNewTable(LocaleIdentifier)
    LocalizationTableCollection.AddNewTable(LocaleIdentifier, String)
    LocalizationTableCollection.RemoveTable(LocalizationTable, Boolean, Boolean)
    LocalizationTableCollection.GetTable(LocaleIdentifier)
    LocalizationTableCollection.RefreshAddressables(Boolean)
    LocalizationTableCollection.ContainsTable(LocalizationTable)
    LocalizationTableCollection.ContainsTable(LocaleIdentifier)
    LocalizationTableCollection.AddExtension(CollectionExtension)
    LocalizationTableCollection.RemoveExtension(CollectionExtension)
    LocalizationTableCollection.GetRowEnumerator<TTable, TEntry>(IEnumerable<TTable>)
    LocalizationTableCollection.GetRowEnumeratorUnsorted<TTable, TEntry>(IList<TTable>)
    LocalizationTableCollection.AddSharedTableDataToAddressables()
    LocalizationTableCollection.AddTableToAddressables(LocalizationTable, Boolean)
    LocalizationTableCollection.RemoveTableFromAddressables(LocalizationTable, Boolean)
    LocalizationTableCollection.ImportCollectionIntoProject()
    LocalizationTableCollection.RemoveCollectionFromProject()
    ScriptableObject.SetDirty()
    ScriptableObject.CreateInstance(String)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(Object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, Boolean)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, Boolean)
    Object.Destroy(Object, Single)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, Boolean)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, Single)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectOfType<T>()
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.name
    Object.hideFlags
    Namespace: UnityEditor.Localization
    Syntax
    public class StringTableCollection : LocalizationTableCollection, ISerializationCallbackReceiver

    Properties

    DefaultGroupName

    The default value to use for Group.

    Declaration
    protected override string DefaultGroupName { get; }
    Property Value
    Type Description
    String
    Overrides
    LocalizationTableCollection.DefaultGroupName

    RequiredExtensionAttribute

    The required attribute for an extension to be added to this collection through the Editor.

    Declaration
    protected override Type RequiredExtensionAttribute { get; }
    Property Value
    Type Description
    Type
    Overrides
    LocalizationTableCollection.RequiredExtensionAttribute

    StringTables

    A helper property which is the contents of Tables loaded and cast to StringTable.

    Declaration
    public virtual ReadOnlyCollection<StringTable> StringTables { get; }
    Property Value
    Type Description
    ReadOnlyCollection<StringTable>

    TableType

    The type of table stored in the collection.

    Declaration
    protected override Type TableType { get; }
    Property Value
    Type Description
    Type
    Overrides
    LocalizationTableCollection.TableType

    Methods

    ClearAllEntries()

    Removes all the entries from SharedTableData and all Tables that are part of this collection.

    Declaration
    public override void ClearAllEntries()
    Overrides
    LocalizationTableCollection.ClearAllEntries()

    GenerateCharacterSet(LocaleIdentifier[])

    Returns a string that contains all the unique characters that are used for all localized values in the tables that belong to the supplied LocaleIdentifier's. This will also include Smart String entries but will only consider the UnityEngine.Localization.SmartFormat.Core.Parsing.LiteralText values, it will not consider UnityEngine.Localization.SmartFormat.Core.Parsing.Placeholder values.

    Declaration
    public string GenerateCharacterSet(params LocaleIdentifier[] localeIdentifiers)
    Parameters
    Type Name Description
    LocaleIdentifier[] localeIdentifiers

    The tables to be included.

    Returns
    Type Description
    String

    All distinct characters or an empty string if no tables or entries.

    GetRowEnumerator()

    Returns an enumerator that can be used to step through each key and its localized values, such as in a foreach loop. Internally SharedTableData and StringTable's are separate assets with their own internal list of values. This means that when iterating through each key a lookup must be made in each table in order to retrieve the localized value, this can become slow when dealing with a large number of tables and entries. GetRowEnumerator improves this process by first sorting the multiple internal lists and then stepping through each conceptual row at a time. It handles missing keys and table entries and provides a more efficient and faster way to iterate through the tables.

    Declaration
    public IEnumerable<LocalizationTableCollection.Row<StringTableEntry>> GetRowEnumerator()
    Returns
    Type Description
    IEnumerable<LocalizationTableCollection.Row<StringTableEntry>>
    Examples

    This example shows how a StringTableCollection could be exported as CSV.

    [MenuItem("CONTEXT/StringTableCollection/Print CSV")]
    public static void CreateCSV(MenuCommand command)
    {
        var collection = command.context as StringTableCollection;
    
        StringBuilder sb = new StringBuilder();
    
        // Header
        sb.Append("Key,");
        foreach (var table in collection.StringTables)
        {
            sb.Append(table.LocaleIdentifier);
            sb.Append(",");
        }
        sb.Append("\n");
    
        // Add each row
        foreach (var row in collection.GetRowEnumerator())
        {
            // Key column
            sb.Append(row.KeyEntry.Key);
            sb.Append(",");
    
            foreach (var tableEntry in row.TableEntries)
            {
                // The table entry will be null if no entry exists for this key
                sb.Append(tableEntry == null ? string.Empty : tableEntry.Value);
                sb.Append(",");
            }
            sb.Append("\n");
        }
    
        // Print the contents. You could save it to a file here.
        Debug.Log(sb.ToString());
    }

    GetRowEnumerator(StringTable[])

    Declaration
    public static IEnumerable<LocalizationTableCollection.Row<StringTableEntry>> GetRowEnumerator(params StringTable[] tables)
    Parameters
    Type Name Description
    StringTable[] tables
    Returns
    Type Description
    IEnumerable<LocalizationTableCollection.Row<StringTableEntry>>

    GetRowEnumeratorUnsorted()

    Returns an enumerator that can be used to step through each key and its localized values, such as in a foreach loop. This version does not sort the items by the Key Id but instead returns them in the order of the Entries. If the order of the rows is not important then using GetRowEnumerator() will provide better performance.

    Declaration
    public IEnumerable<LocalizationTableCollection.Row<StringTableEntry>> GetRowEnumeratorUnsorted()
    Returns
    Type Description
    IEnumerable<LocalizationTableCollection.Row<StringTableEntry>>

    RemoveEntry(TableEntryReference)

    Removes the entry from the SharedTableData and all tables that are part of this collection.

    Declaration
    public override void RemoveEntry(TableEntryReference entryReference)
    Parameters
    Type Name Description
    TableEntryReference entryReference
    Overrides
    LocalizationTableCollection.RemoveEntry(TableEntryReference)

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Properties
      • DefaultGroupName
      • RequiredExtensionAttribute
      • StringTables
      • TableType
    • Methods
      • ClearAllEntries()
      • GenerateCharacterSet(LocaleIdentifier[])
      • GetRowEnumerator()
      • GetRowEnumerator(StringTable[])
      • GetRowEnumeratorUnsorted()
      • RemoveEntry(TableEntryReference)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023