ResourceDatabase
Resolves localized strings and assets for the active localization settings.
Read time 2 minutesLast updated 8 days ago
Definition
- Type: Class
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
public class ResourceDatabase
Remarks
A resource database owns an AssetProvider chain and an internal per-locale asset cache. Access the active database through LocalizationSettings.Database. Tables load through the provider chain like any other asset (the database keeps no table list), so use the reference types TableReference and TableEntryReference to identify what to resolve. String entries flagged as Smart are formatted through the settings' Smart formatter (see LocalizationSettings.GetSmartFormatter), and resolved values pass through the locale's post-processing hook, which pseudo-locales use to transform text. Each resolve method has an asynchronous form that loads on demand and a synchronous form that reads only already-loaded tables. Missing or empty entries follow the locale fallback chain defined by Locale.FallbackCode.
Additional Resources: LocalizationSettings, ResourceTable, TableReference, TableEntryReference, LocalizedString, Locale, AssetProvider
Resolves a localized string in the selected locale.
Examples
using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class ResolveLocalizedStringExample : MonoBehaviour { async void Start() { ResourceDatabase database = LocalizationSettings.ResourceDatabase; string text = await database.GetLocalizedStringAsync("UI Text", "hello"); Debug.Log(text); } }}
Properties
Property | Description |
|---|---|
| AssetProvider | The provider chain used to load tables and localized assets. |
Methods
Method | Description |
|---|---|
| GetEntry | Resolves an entry synchronously, following the fallback chain, or null when an async load is required. |
| GetEntryAsync | Resolves an entry, following the locale fallback chain when the entry is missing or empty. |
| GetLocalizedAsset | Resolves a localized asset synchronously from a synchronous provider and entry. |
| GetLocalizedAssetAsync | Resolves a localized asset: the direct reference when present, otherwise through the provider chain. |
| GetLocalizedString | Resolves a localized string synchronously, or null when it cannot be resolved without an asynchronous load. |
| GetLocalizedStringAsync | Resolves a localized string, applying Smart formatting and the locale post-processing hook. |
| GetTable | Returns the resource table for a reference if it is already loaded, or null otherwise. |
| GetTableAsync | Loads the resource table for a table reference in a locale through the provider chain. |
| ReleaseAllAssets | Releases every cached asset across all locales. |
| ReleaseAssets | Releases every cached asset loaded for the given locale. |