Version: Unity 6.7 Beta (6000.7)
Language : English
Localize strings
Localize UI created with UI Toolkit

Localize assets

Swap textures, audio, and other assets per language.

Asset entries in collection tables work like string entries, so they have one key and one asset per locale. Use them for anything visual or audible that changes with language, for example a texture containing text, a voice-over clip, or a font.

Prerequisites

Before you start, make sure you have the following:

Add an asset entry

To add an asset entry to a collection:

  1. Open Window > Localization > Resource Tables and select the collection.
  2. Create a key and choose the asset entry type.
  3. Assign each locale’s asset in its column.

Each asset entry stores its value in one of two ways:

Storage Description
Direct The table references the asset, and the asset loads when the table loads. This is the simplest option, but every referenced asset ships and loads with the table.
Resources The table stores a path into a Resources folder, and the asset loads on demand.

For a Resources entry, place the asset under a Resources folder yourself before assigning it. If the asset isn’t under Resources, the entry can’t store a path and the Unity Editor logs a warning.

Use the asset

Reference localized assets in your scripts by using a LocalizedAsset<TObject> field, or one of the built-in types: LocalizedTexture, LocalizedSprite, LocalizedFont, LocalizedMaterial, LocalizedGameObject, or LocalizedObject.

Subscribe to AssetChanged to receive the asset when it resolves and again on every language change. To pull an asset on demand instead, call GetLocalizedAsset or its asynchronous counterpart GetLocalizedAssetAsync.

Note: Whether the synchronous call can succeed depends on the entry’s storage and the content source. Direct references resolve synchronously. Other sources might only support asynchronous loading. Refer to Synchronous and asynchronous loading.

Localize without code

Add a Localize Texture Event component (LocalizeTextureEvent) and wire its event to the property that displays the texture. For other asset types, derive a small component from LocalizeAssetEvent<TObject>.

Release loaded assets

The database caches loaded assets per locale. To free them, for example after you leave a scene, call ReleaseAssets on the database, or ReleaseAllAssets.

Additional resources

Localize strings
Localize UI created with UI Toolkit