Generate dynamic text
Build text from your project's data at runtime, using templates that handle plurals, conditions, and lists.
Read time 1 minuteLast updated a day ago
Smart Strings are a Unity port of the SmartFormat library. They're an alternative to for text that has to change at runtime, such as a score readout, a notification, or a line of dialog. Because the logic lives in the template rather than in your C# code, a designer or translator can edit the text without touching a script.
String.FormatA Smart String is made of literal text and placeholders. Sources evaluate a placeholder to produce a value, and formatters convert that value into text.
Topic | Description |
|---|---|
| Introduction to Smart Strings | Understand how Smart Strings format dynamic text using named placeholders, sources, and formatters. |
| Configure Smart Strings | Set up a project-wide default formatter and customize Smart Strings formatting in code. |
| Smart Strings settings reference | Customize the settings that control the project's default Smart String formatter. |
| Handle formatting errors | Control how Smart Strings react to invalid format strings, and track the failures that happen. |
| Smart Strings performance | Reduce allocations and re-parsing when you format the same Smart String repeatedly, and understand the thread-safety constraints of a formatter. |
| Populate strings with data using Sources | Browse the sources that evaluate a placeholder's selectors to produce the value to format. |
| Use formatters to apply logic to strings | Browse the formatters that convert a selected value into text in a Smart String. |