Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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
String.Format
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.
A 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 StringsUnderstand how Smart Strings format dynamic text using named placeholders, sources, and formatters.
Configure Smart StringsSet up a project-wide default formatter and customize Smart Strings formatting in code.
Smart Strings settings referenceCustomize the settings that control the project's default Smart String formatter.
Handle formatting errorsControl how Smart Strings react to invalid format strings, and track the failures that happen.
Smart Strings performanceReduce 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 SourcesBrowse the sources that evaluate a placeholder's selectors to produce the value to format.
Use formatters to apply logic to stringsBrowse the formatters that convert a selected value into text in a Smart String.

Additional resources