| Parameter | Description |
|---|---|
| keyId | The stable key id to look up. |
IResourceEntry
The matching entry, or null when none exists.
Returns the entry stored for a stable key id.
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.
Additional resources: ResourceTable.GetEntry, ResourceTable.GetEntry, ResourceTable.AddEntry
<para>Look up an entry by the key id of a previously added string.</para>
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 } } }
| Parameter | Description |
|---|---|
| keyId | The stable key id to look up. |
T
The matching entry as T, or null when it is missing or a different kind.
Returns the entry stored for a stable key id as a specific entry kind.
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.
Additional resources: ResourceTable.GetEntry, ResourceTable.GetEntry, IStringEntry
<para>Read a value by fetching the entry as a typed string entry.</para>
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 } } }
| Parameter | Description |
|---|---|
| key | The key text to look up. |
IResourceEntry
The matching entry, or null when none exists.
Returns the entry stored for a key.
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.
Additional resources: ResourceTable.GetEntry, ResourceTable.GetEntry, ResourceTable.SharedData
<para>Look up an entry by its key text.</para>
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 } } }
| Parameter | Description |
|---|---|
| key | The key text to look up. |
T
The matching entry as T, or null when it is missing or a different kind.
Returns the entry stored for a key as a specific entry kind.
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.
Additional resources: ResourceTable.GetEntry, ResourceTable.GetEntry, IStringEntry
<para>Read a value by fetching the entry for a key as a typed string entry.</para>
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 } } }