docs.unity3d.com
    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
    Back to top
    Terms of use
    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