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.
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 } |
|
one, two, and three |
{theKey:ismatch(^.+123.+$):Fixed content if match|No match content} |
|
Fixed content if match |
{0:list:{:ismatch(^100|200|999$):{:0.00}|'no match'}|, | and } |
|
100.00, 200.00 and 'no match' |
{0:list:{:ismatch(^100|200|999$):'match'|'no match'}|, | and } |
|
'match', 'match' and 'no match' |
The index placeholder can be used to sync multiple lists such as: {0:{} = {1.index}|, } |
|
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));