Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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.
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

AssetProviderThe provider chain used to load tables and localized assets.

Methods

Method

Description

GetEntryResolves an entry synchronously, following the fallback chain, or null when an async load is required.
GetEntryAsyncResolves an entry, following the locale fallback chain when the entry is missing or empty.
GetLocalizedAssetResolves a localized asset synchronously from a synchronous provider and entry.
GetLocalizedAssetAsyncResolves a localized asset: the direct reference when present, otherwise through the provider chain.
GetLocalizedStringResolves a localized string synchronously, or null when it cannot be resolved without an asynchronous load.
GetLocalizedStringAsyncResolves a localized string, applying Smart formatting and the locale post-processing hook.
GetTableReturns the resource table for a reference if it is already loaded, or null otherwise.
GetTableAsyncLoads the resource table for a table reference in a locale through the provider chain.
ReleaseAllAssetsReleases every cached asset across all locales.
ReleaseAssetsReleases every cached asset loaded for the given locale.