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

ResourceEntryBase

class 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

Serves as the base class for the built-in resource entry kinds, holding the stable key id and per-entry metadata.

This class implements the storage that every entry kind shares: the ResourceEntryBase.KeyId that ties the entry to a shared key, and the ResourceEntryBase.Metadata for that entry. Concrete kinds add their value on top, for example StringEntry for text or AssetEntry for an object reference. Derive from this class (or from AssetEntryBase<T0>) to add a custom entry kind. Entries are stored polymorphically in a ResourceTable, so a new kind needs no change to the table.

Additional resources: StringEntry, AssetEntryBase<T0>, IResourceEntry, ResourceTable

<para>Read the shared members through a concrete string entry.</para>

using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples { public class ResourceEntryBaseOverviewExample { public void Run() { var shared = ScriptableObject.CreateInstance<SharedTableData>(); shared.TableCollectionName = "UI Text";

var table = ScriptableObject.CreateInstance<ResourceTable>(); table.SharedData = shared; table.LocaleIdentifier = new LocaleIdentifier("en");

StringEntry entry = table.AddStringEntry("greeting", "Hello");

ResourceEntryBase baseEntry = entry; // StringEntry derives from ResourceEntryBase Debug.Log(baseEntry.KeyId); Debug.Log(baseEntry.Metadata.HasData); } } }