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
The stable key id to look up.
Returns
Type | Description |
|---|---|
| IResourceEntry | The matching entry, or |
Remarks
Looks the id up among this table's entries. Returns when the id is or when no entry exists for it. To narrow the result to a specific entry kind, use ResourceTable.GetEntry.
null0Look 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
The stable key id to look up.
Returns
Type | Description |
|---|---|
| T | The matching entry as |
Remarks
Casts the result of ResourceTable.GetEntry to . Returns 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.
TnullRead 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 |
|---|---|
| IResourceEntry | The matching entry, or |
Remarks
Resolves the key text to its stable id through ResourceTable.SharedData, then returns the matching entry. Returns 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.
nullLook 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 |
|---|---|
| T | The matching entry as |
Remarks
Resolves the key text through ResourceTable.SharedData, then casts the result of ResourceTable.GetEntry to . Returns 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.
TnullRead 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 } }}