Class UnityUiTMP_TextLocalizationUpdaterComponent
Unity component that manages TextMeshPro text localization using Unity's Localization system.
Automatically updates localized strings based on current text content and provides manual refresh capabilities.
Integrates with Unity Localization package to provide dynamic text translation for UI elements.
Namespace: Serenity.Ui.Infrastructure.Components
Assembly: Serenity.UnityUi.Infrastructure.dll
Syntax
public class UnityUiTMP_TextLocalizationUpdaterComponent : MonoBehaviour
Constructors
UnityUiTMP_TextLocalizationUpdaterComponent()
Declaration
public UnityUiTMP_TextLocalizationUpdaterComponent()
Methods
GetText()
Provides access to the associated TextMeshPro text component.
Returns the text component used for displaying localized content.
Declaration
public TMP_Text GetText()
Returns
| Type | Description |
|---|---|
| TMP_Text | The TMP_Text component managed by this localization updater |
SetTranslateOnStart(bool)
Sets whether to perform initial localization on component start.
Allows external configuration of translation behavior before the Start lifecycle method executes.
Must be called before Start() to affect initial localization behavior.
Declaration
public void SetTranslateOnStart(bool translateOnStart)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | translateOnStart | True to enable translation on start, false to disable |
UpdateLocalization()
Updates the localization settings and refreshes the displayed text.
Sets the current text content as the localization table entry reference and triggers string refresh.
Uses the Global localization table for text resolution.
Two paths:
- Unity Localization path (default — used whenever the
service exposes a non-empty GetStringTableReference()).
Delegates the actual string lookup to
LocalizeStringEvent.RefreshString, which goes through Unity Localization's Addressables-backed table registry. Untouched from the pre-Slice-AA behaviour. - Fallback path (Slice AA — used in
ResourcesOnly/WebGL mode, where GetStringTableReference() intentionally returns an empty string so this branch is taken). Asks the service to translate the raw key directly via TryTranslate(string, out string), which the fallback service resolves against translation JSON the WebGL exporter wrote into the consumer'sResources/Localization/tree. On a miss the original key text is left on screen — same behaviour as before Slice AA.
Declaration
public void UpdateLocalization()