docs.unity3d.com
    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 Sprite asset.

    using System;
    using UnityEngine.Events;
    
    public class LocalizeSpriteBehaviour : LocalizedAssetEvent<Sprite>
    {
    }
    

    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. If you use String Component Localizers, Unity also selects the table and key that most closely matches the text.

    Localize Component menu.

    Localize String Component.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023