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

IAssetEntry

interface in Unity.Localization


Implements interfaces:IResourceEntry

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

Represents a resource entry whose localized value is an asset that the entry loads and releases itself.

Each concrete kind owns how its asset is referenced and resolved: AssetEntry keeps a direct object reference, ResourceAssetEntry stores a Resources path, and a package can add other kinds such as an Addressables-backed entry. An entry opts into loading by implementing IAsyncAssetEntry, ISynchronousAssetEntry, or both; the localization system prefers the asynchronous version and falls back to the synchronous one. Every loaded asset should be handed back with IAssetEntry.ReleaseAsset so the owning kind can free it. Fetch an asset entry from a table with ResourceTable.GetEntry using IAssetEntry as the type argument.

Additional resources: AssetEntry, ResourceAssetEntry, AssetEntryBase<T0>, IAsyncAssetEntry, ISynchronousAssetEntry

<para>Check whether an asset entry has a value assigned.</para>

using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples { public class IAssetEntryOverviewExample { 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");

table.AddEntry(new AssetEntry(shared.AddKey("icon").Id)); IAssetEntry entry = table.GetEntry<IAssetEntry>("icon");

Debug.Log(entry.HasAsset()); // False: no asset assigned yet } } }

Public Methods

Method Description
HasAsset Returns whether this entry has an asset assigned.
ReleaseAsset Releases an asset previously returned by a load.