Version: Unity 6.7 Alpha (6000.7)
Language : English
Use Formatters to apply logic to strings
Conditional formatter

Choose formatter

Select one of several outputs based on the value of a placeholder.

The Choose formatter adds branching logic to a Smart String: it matches the placeholder value against a set of options and outputs the corresponding choice. Apply it explicitly with the name choose.

Anatomy of the choose formatter syntax.
Anatomy of the choose formatter syntax.

The value is converted to a string with ToString and matched against the options, so you can use it on any type, including numbers, booleans, strings, or enums. null is also supported.

To supply a fallback output for any values that don’t match any of the choices, add an extra output option at the end of the outputs segment.

Choices are case-sensitive by default, but you can configure this behavior with the case sensitivity setting. Refer to Smart Strings settings reference for information on the different settings and how to enable them.

Smart String Argument Result
{0:choose(1\|2\|3):one\|two\|three\|other} 2 two
{0:choose(1\|2\|3):one\|two\|three\|other} 5 other
{0:choose(True\|False):yes\|no} true yes
{0:choose(null):NULL\|{}} null NULL
How {0:choose(Male\|Female):is he\|is she\|are they}? "Male" How is he?
It is {day:choose(1\|2\|3\|4\|5):Mon\|Tue\|Wed\|Thur\|Fri\|the weekend}. 7 It is the weekend.

Additional resources

Use Formatters to apply logic to strings
Conditional formatter