Component Localizers | Localization | 0.6.1-preview
docs.unity3d.com
    Show / Hide Table of Contents

    Component Localizers

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

    LocalizedString

    The LocalizedString Component Localizer can be used to localize string components and provide 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. The LocalizedString editor can be used to edit tables, localized strings and preview them after formatting.

    Localize String Editor.

    LocalizedAssetBehaviour

    LocalizedAssetBehaviour can be used to Localize a Unity asset, such as a Texture or Audio clip. LocalizedAssetBehaviour is 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(LocalizeTextureBehaviour) and Audio Clip(LocalizeAudioClipBehaviour).

    Localize Texture Editor.

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

    using System;
    using UnityEngine.Events;
    
    public class LocalizeSpriteBehaviour : LocalizedAssetBehaviour<Sprite>
    {
        [Serializable]
        public class UnityEventSprite : UnityEvent<Sprite> { }
    
        [SerializeField]
        UnityEventSprite m_UpdateAsset = new UnityEventSprite();
    
        protected override void UpdateAsset(Sprite localizedAsset)
        {
            OnUpdateAsset.Invoke(localizedAsset);
        }
    }
    

    Automatic Setup

    Some Unity Components can be automatically set up with a Component Localizer. These Components will have a Localize option in their context menus. A new Component Localizer will be added and its events hooked up to the target component, when using String Component Localizers the closest table and key will also be selected.

    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