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

ResourceTable.GetEntry

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

Declaration

public IResourceEntry GetEntry(long keyId);

Parameters

Parameter Description
keyId The stable key id to look up.

Returns

IResourceEntry The matching entry, or null when none exists.

Description

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 } } }

Declaration

public T GetEntry(long keyId);

Parameters

Parameter Description
keyId The stable key id to look up.

Returns

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

Description

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 } } }

Declaration

public IResourceEntry GetEntry(string key);

Parameters

Parameter Description
key The key text to look up.

Returns

IResourceEntry The matching entry, or null when none exists.

Description

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 } } }

Declaration

public T GetEntry(string key);

Parameters

Parameter Description
key The key text to look up.

Returns

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

Description

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 } } }