Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetEntry

Returns the entry stored for a stable key id.
Read time 3 minutesLast updated 13 days ago

Definition

  • Type: Method
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule

GetEntry(long)

Returns the entry stored for a stable key id.
public IResourceEntry GetEntry(long keyId)

Parameters

keyId

The stable key id to look up.

Returns

Type

Description

IResourceEntryThe matching entry, or
null
when none exists.

Remarks

Looks the id up among this table's entries. Returns
null
when the id is
0
or when no entry exists for it. To narrow the result to a specific entry kind, use ResourceTable.GetEntry.
Look up an entry by the key id of a previously added string.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class ResourceTableGetEntryByIdExample { public void Run() { var shared = ScriptableObject.CreateInstance<SharedTableData>(); var table = ScriptableObject.CreateInstance<ResourceTable>(); table.SharedData = shared; table.LocaleIdentifier = "en"; var added = table.AddStringEntry("Greeting", "Hello"); IResourceEntry entry = table.GetEntry(added.KeyId); Debug.Log(entry != null); // True } }}

GetEntry<T>(long)

Returns the entry stored for a stable key id as a specific entry kind.
public T GetEntry<T>(long keyId) where T : class, IResourceEntry

Parameters

keyId

The stable key id to look up.

Returns

Type

Description

TThe matching entry as
T
, or
null
when it is missing or a different kind.

Remarks

Casts the result of ResourceTable.GetEntry to
T
. Returns
null
when no entry exists for the id or when the entry is not of that kind. Pass an entry class such as StringEntry or a view interface such as IStringEntry.
Read a value by fetching the entry as a typed string entry.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class ResourceTableGetEntryOfTypeByIdExample { public void Run() { var shared = ScriptableObject.CreateInstance<SharedTableData>(); var table = ScriptableObject.CreateInstance<ResourceTable>(); table.SharedData = shared; table.LocaleIdentifier = "en"; var added = table.AddStringEntry("Greeting", "Hello"); StringEntry entry = table.GetEntry<StringEntry>(added.KeyId); Debug.Log(entry.Value); // Hello } }}

GetEntry(string)

Returns the entry stored for a key.
public IResourceEntry GetEntry(string key)

Parameters

The key text to look up.

Returns

Type

Description

IResourceEntryThe matching entry, or
null
when none exists.

Remarks

Resolves the key text to its stable id through ResourceTable.SharedData, then returns the matching entry. Returns
null
when no shared data is assigned, the key is absent, or this table has no entry for it. To narrow the result to a specific entry kind, use ResourceTable.GetEntry.
Look up an entry by its key text.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class ResourceTableGetEntryByKeyExample { public void Run() { var shared = ScriptableObject.CreateInstance<SharedTableData>(); var table = ScriptableObject.CreateInstance<ResourceTable>(); table.SharedData = shared; table.LocaleIdentifier = "en"; table.AddStringEntry("Greeting", "Hello"); IResourceEntry entry = table.GetEntry("Greeting"); Debug.Log(entry != null); // True } }}

GetEntry<T>(string)

Returns the entry stored for a key as a specific entry kind.
public T GetEntry<T>(string key) where T : class, IResourceEntry

Parameters

The key text to look up.

Returns

Type

Description

TThe matching entry as
T
, or
null
when it is missing or a different kind.

Remarks

Resolves the key text through ResourceTable.SharedData, then casts the result of ResourceTable.GetEntry to
T
. Returns
null
when the key cannot be resolved, no entry exists, or the entry is not of that kind. Pass an entry class such as StringEntry or a view interface such as IStringEntry.
Read a value by fetching the entry for a key as a typed string entry.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class ResourceTableGetEntryOfTypeByKeyExample { public void Run() { var shared = ScriptableObject.CreateInstance<SharedTableData>(); var table = ScriptableObject.CreateInstance<ResourceTable>(); table.SharedData = shared; table.LocaleIdentifier = "en"; table.AddStringEntry("Greeting", "Hello"); IStringEntry entry = table.GetEntry<IStringEntry>("Greeting"); Debug.Log(entry.Value); // Hello } }}