Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

AssetEntryBase<T0>

class in Unity.Localization

/

Inherits from:Unity.Localization.ResourceEntryBase


Implements interfaces:IAssetEntry, IResourceEntry, ISynchronousAssetEntry

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

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

Properties

Property Description
Default The stored reference this entry loads its asset from.

Protected Methods

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.

Inherited Members