Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ReferencedAssetProvider

An asset provider that resolves an address to a directly referenced asset. Use it when assets are assigned by reference rather than loaded from built content, a Resources folder, or Addressables.
Read time 1 minuteLast updated 12 days ago

Definition

public sealed class ReferencedAssetProvider : IAssetProvider, ISynchronousAssetProvider

Remarks

The address-to-reference map is populated through ReferencedAssetProvider.Add, so AssetKey.Address is the key into that map. Loads complete immediately because the assets are already in memory. ReferencedAssetProvider.Release is a no-op: the references are owned by whatever holds this provider, so there is nothing to unload. The map is authored programmatically by the table editor, so it is hidden from the inspector.
Register a texture by address and load it back through the provider.

Examples

using Unity.Localization.Providers;using UnityEngine;namespace Unity.Localization.Samples{ public class ReferencedAssetProviderOverviewExample { public void Run() { var provider = new ReferencedAssetProvider(); provider.Add("UI/Logo", new Texture2D(2, 2)); var resolved = provider.TryLoadAsset<Texture2D>(new AssetKey("UI/Logo", typeof(Texture2D)), out var logo); Debug.Log(resolved); // True Debug.Log(logo != null); // True } }}

Methods

Method

Description

AddMaps an address to a directly referenced asset, replacing any existing mapping for that address.
ContainsChecks whether an asset is registered under the given address.
ReleaseDoes nothing, because this provider does not own the assets it returns.
RemoveRemoves any entry registered under the given address.
TryLoadAssetResolves the referenced asset for the key without an asynchronous load.