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

    EnsureRuntimeBinding()

    Wires the LocalizeStringEvent to write the localized value back into the TMP_Text when the component is attached at runtime (where the prefab-time persistent listener on OnUpdateString is not present). Idempotent and safe to call multiple times. Has no effect when a persistent listener already exists (prefab path).

    Declaration
    public void EnsureRuntimeBinding()

    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

    SetLocalizationKey(string)

    Sets an explicit localization key to use for subsequent UpdateLocalization() calls. When set, the key is preserved across refreshes (including locale changes that re-trigger UpdateLocalization() via Serenity.Ui.Infrastructure.Components.UnityUiTMP_TextLocalizationUpdaterComponent.Start or external callers), so the TMP_Text content (which holds the resolved/localized value after the first refresh) is never re-interpreted as a new key. Pass null or empty to clear the cached key and fall back to reading the current TMP_Text content as the key (legacy behavior used by menu/button/dropdown callers that rewrite the TMP_Text content per refresh).

    Declaration
    public void SetLocalizationKey(string key)
    Parameters
    Type Name Description
    string key

    The localization key to cache, or null/empty to clear it.

    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.

    Declaration
    public void UpdateLocalization()
    In this article
    © 2026 Serenity. All Rights Reserved