logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    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.

    Inheritance
    object
    UnityUiTMP_TextLocalizationUpdaterComponent
    Namespace: Serenity.Ui.Infrastructure.Components
    Assembly: Serenity.UnityUi.Infrastructure.dll
    Syntax
    public class UnityUiTMP_TextLocalizationUpdaterComponent : MonoBehaviour

    Constructors

    UnityUiTMP_TextLocalizationUpdaterComponent()

    Declaration
    public UnityUiTMP_TextLocalizationUpdaterComponent()

    Methods

    ConfigureFor(TMP_Text, bool)

    Configures runtime localization for any TMP whose displayed text should be treated as a localization key — the shared model behind title/body text (UnityModalComponent), button labels (UnityUiInteractableDecorationCoordinator.ConfigureLabelLocalization), and toast messages (UnityToastComponent). When translate is true the assigned text is treated as a localization key. The updater component is added on demand if missing — its [RequireComponent] + self-healing dependency resolution make runtime AddComponent safe, so no prefab edit is required.

    Declaration
    public static void ConfigureFor(TMP_Text text, bool translate)
    Parameters
    Type Name Description
    TMP_Text text

    The TMP whose GameObject should host the localization updater.

    bool translate

    Whether the current text should be localized.

    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:

    1. 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.
    2. 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's Resources/Localization/ tree. On a miss the original key text is left on screen — same behaviour as before Slice AA.
    Declaration
    public void UpdateLocalization()
    In this article
    © 2026 Serenity. All Rights Reserved