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.
Before you start, make sure you have the following:
To add an asset entry to a collection:
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.
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.
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>.
The database caches loaded assets per locale. To free them, for example after you leave a scene, call ReleaseAssets on the database, or ReleaseAllAssets.