Version: Unity 6.7 Alpha (6000.7)
Language : English
Properties source
Create a custom source

String source

Transform string values with built-in string operations inside a Smart String.

The String source handles a string value and exposes common string operations as selectors, so you can transform text directly in the format string. For example, {name.ToUpper} outputs the value of name in uppercase.

Selector Description
Length The number of characters in the string.
ToUpper, ToLower Convert to upper or lower case using the active culture.
ToUpperInvariant, ToLowerInvariant Convert to upper or lower case using the invariant culture.
Trim, TrimStart, TrimEnd Remove surrounding whitespace.
Capitalize Convert the first character to upper case.
CapitalizeWords Convert the first letter of each word to upper case.
ToCharArray Convert the string to a character array.
ToBase64, FromBase64 Encode to, or decode from, a UTF–8 Base64 string.

The following examples show how to use a few common string operations with the String source:

Smart.Format("{0.ToUpper}", "hello");                // "HELLO"
Smart.Format("{0.Capitalize}", "hello");             // "Hello"
Smart.Format("{0.CapitalizeWords}", "hello world");  // "Hello World"
Smart.Format("Length: {0.Length}", "hello");         // "Length: 5"
  • Selectors are matched case-insensitively unless case-sensitive matching is enabled in the settings. Refer to Smart Strings settings reference for information on the different settings and how to enable them.
  • Enable Use Invariant Culture on the source to always use the invariant culture. Otherwise, the active culture is used for case conversions.

Additional resources

Properties source
Create a custom source