Hi there, I’m trying to use smart strings in localization but I’m not able to figure out how to setup it correctly via script on a prefab.
I will present the situation below:
The DataRT class will manage informations given by 4 classes and will create, for each of them, a prefab (InfoDataListItem), which is a UI Information Panel with 4 texts showing informations.

DataRT Script with InfoDataListItem prefab reference

Prefab InfoDataListItem
InfoDataListItem has the following structure (left) and setup (right):

Every text (Title UI, Subtitle UI, etc…) references to its relative TextMeshPro text.
Only SubTitle texts are SmartStrings and the text structure is like this:
“last 5 min”, “last 25 min”
or
“last 5 sec”, “last 25 sec”
To generate strings like the examples above I created entries like:
So, there are two words (quantityTime and unitTime) to update every 5 sec, where quantityTime=5,10,15,… and unitTime=min,sec.
The text will be updated every 5 seconds by changing its values (quantityTime and unitTime) AND when the language is changed.
Now, the goals is to generate these prefabs at runtime, adding a LocalizeStringEvent component and setting up it.
With the following code:
// Get subtitle text
TextMeshProUGUI textToUpdate = uiElement.GetComponent<DataRTElement>().SubtitleUi;
// Setup LocalizeStringEvent
LocalizedString localizeString = new LocalizedString(data.DataRTValueLocalizer.TableName, data.DataRTValueLocalizer.SubtitleLocalized);
// Add local variables to update
localizeString.Add("quantityTime", new IntVariable { Value = 0 });
localizeString.Add("unitTime", new StringVariable { Value = "min" });
uiElement.GetComponent<LocalizeStringEvent>().StringReference = localizeString;
… I’m able to reach the result above:
Looking at the result:
- the StringReference refers to the right table and entry
. - the LocalVariables are assigned correctly, but they should come from another class which has the variables with updated values
. - I’m not able to setup UpdateString. There should be a reference to the text of Subtitle as the target text to be updated
.
Can anyone help me set everything up correctly? Thank you!

