docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    List Formatter

    The List Formatter is a Source and a Formatter. You can use it as a Formatter to repeat the contents of any IEnumerable, such as an Array or List.

    Diagram showing the breakdown of the Smart String and how each part is evaluated.

    The spacers can also include character literals, for example, instead of a comma you could also use \n to list each item on a new line. Use the placeholder index to access the current index of the list being iterated. You can use this to access multiple lists.

    Example Smart String Arguments Result
    {0:list:{}|, |, and }
    new[] { "one", "two", "three" }
    
    one, two, and three
    {theKey:ismatch(^.+123.+$):Fixed content if match|No match content}
    new Dictionary<string, object>() { {"theKey", "Some123Content"}}
    
    Fixed content if match
    {0:list:{:ismatch(^100|200|999$):{:0.00}|'no match'}|, | and }
    new List<int> {100, 200, 300}
    
    100.00, 200.00 and 'no match'
    {0:list:{:ismatch(^100|200|999$):'match'|'no match'}|, | and }
    new List<int> {100, 200, 300}
    
    'match', 'match' and 'no match'
    The index placeholder can be used to sync multiple lists such as:

    {0: = {1.index}|, }

    new List<int> { 1, 2, 3, 4 },
    new List<string> { "one", "two", "three", "four" }
    
    The index placeholder can be used to sync multiple lists such as:

    1 = one, 2 = two, 3 = three, 4 = four

    Localized String Example

    This example shows how to pass a list as an argument to a LocalizedString.

    Note

    The list must be one of the arguments, in this example it is argument 0.

    // Text: "Use {0:list:{}|, |, and } to move".
    var myLocalizedString = new LocalizedString("My Table", "My Entry");
    myLocalizedString.Arguments = new object[] { new object[] { "w", "a", "s", "d" } };
    
    // Outputs "Use w, a, s and d to move"
    Debug.Log(myLocalizedString.GetLocalizedString(myLocalizedString));
    
    In This Article
    Back to top
    Copyright © 2025 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)