docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Component Localizers

    Component Localizers are MonoBehaviours which you can connect to other components/scripts through UnityEvents. Component Localizers allow for localizing without the need to write any scripts.

    LocalizeStringEvent

    The LocalizeStringEvent Component Localizer localizes strings and provides additional arguments when using Smart Strings or String.Format. In the Inspector, Format Arguments must be UnityEngine.Objects; however, it is possible to pass any type through as an argument via script. You can also use the LocalizeStringEvent editor to edit tables and Localized strings, and preview them after formatting.

    Localize String Editor.

    LocalizedAssetEvent

    LocalizeAssetEvent can localize a Unity asset, such as a Texture or Audio clip. LocalizedAssetEventis an abstract class that should be inherited from in order to set the Asset type. The Localization System currently features some implemented versions of LocalizedAssetBehaviour for Texture(LocalizeTextureEvent) and Audio Clip(LocalizeAudioClipEvent).

    Localize Texture Editor.

    This example shows how support could be added for the Font asset.

    
    using System;
    using UnityEngine;
    using UnityEngine.Localization;
    using UnityEngine.Localization.Components;
    using UnityEngine.UI;
    
    [Serializable]
    public class LocalizedFont : LocalizedAsset<Font> {}
    
    public class LocalizedFontComponent : LocalizedAssetBehaviour<Font, LocalizedFont>
    {
        public Text text;
    
        protected override void UpdateAsset(Font localizedFont)
        {
            text.font = localizedFont;
        }
    }
    

    Automatic Setup

    Some Unity components allow you to add an automatic Component Localizer to them. These components have a Localize option in their context menus. When you select this, Unity adds a new Component Localizer and hook its events up to the target component.

    The following components support automatic setup:

    • Text
    • RawImage
    • Image
    • Text - TextMeshPro
    • AudioSource

    Localize Component menu.

    Localize String Component.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)