class in Unity.Localization
/
Inherits from:Unity.Localization.ResourceEntryBase
Implements interfaces:IAssetEntry, IResourceEntry, ISynchronousAssetEntry
Serves as the base class for asset entries that own a stored reference and load and release the asset themselves.
The type parameter is the stored reference the entry keeps in AssetEntryBase<T0>.Default, and each concrete kind decides
how that reference resolves to an asset: AssetEntry stores a direct object, and
ResourceAssetEntry stores a Resources path. The built-in kinds are synchronous: they resolve
through ISynchronousAssetEntry.TryLoadAsset, and public callers use the
IAssetEntry members AssetEntryBase<T0>.HasAsset and AssetEntryBase<T0>.ReleaseAsset. To add
a custom kind, override the protected HasValue, TryLoadSync, and Release members to back a
different storage, such as an Addressables handle provided by a package.
Additional resources: AssetEntry, ResourceAssetEntry, IAssetEntry, ResourceTable
<para>Read the base members through a concrete asset entry.</para>
using Unity.Localization; using UnityEngine;
namespace Unity.Localization.Samples { public class AssetEntryBaseOverviewExample { public void Run() { var shared = ScriptableObject.CreateInstance<SharedTableData>(); shared.TableCollectionName = "UI Assets";
var table = ScriptableObject.CreateInstance<ResourceTable>(); table.SharedData = shared; table.LocaleIdentifier = new LocaleIdentifier("en");
var entry = new AssetEntry(shared.AddKey("icon").Id); table.AddEntry(entry);
AssetEntryBase<Object> baseEntry = entry; // AssetEntry derives from AssetEntryBase<Object> Debug.Log(baseEntry.HasAsset()); // False: no asset assigned Debug.Log(baseEntry.Default); // null } } }
| Property | Description |
|---|---|
| Default | The stored reference this entry loads its asset from. |
| Method | Description |
|---|---|
| HasValue | Returns whether the given stored reference holds a value. |
| Release | Releases an asset that was loaded from a stored reference. |
| TryLoadSync | Resolves the asset from the given stored reference synchronously, when the kind supports it. |