Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AssetEntryBase<TStore>

Serves as the base class for asset entries that own a stored reference and load and release the asset themselves.
Read time 2 minutesLast updated 7 days ago

Definition

public abstract class AssetEntryBase<TStore> : ResourceEntryBase, IAssetEntry, IResourceEntry, ISynchronousAssetEntry

Remarks

The type parameter is the stored reference the entry keeps in AssetEntryBase<TStore>.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 HasAsset and 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.
Read the base members through a concrete asset entry.

Examples

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

Constructors

Constructor

Description

AssetEntryBase`1()Creates an empty entry.
AssetEntryBase`1(System.Int64)Creates an entry for a key id.

Properties

Property

Description

DefaultThe stored reference this entry loads its asset from.

Methods

Method

Description

HasValueReturns whether the given stored reference holds a value.
ReleaseReleases an asset that was loaded from a stored reference.
TryLoadSyncResolves the asset from the given stored reference synchronously, when the kind supports it.