| Parameter | Description |
|---|---|
| key | The key text; added to the shared data when new. |
| value | The localized value to store for this locale. |
| isSmart | Whether the value is a Smart String, formatted at resolve time; omit it to leave the key's flag unchanged. |
void
The added or updated entry, or null when it cannot be added.
Adds or updates a plain string entry for a key.
Adds the key to ResourceTable.SharedData when it is new, then stores the value for this locale. When an entry
already exists for the key, its value is overwritten. When isSmart is supplied it is stored
on the shared key, so it applies to every locale and can turn an existing key back into a plain string; when it
is omitted the key's existing flag is left unchanged. Returns null when no shared data is
assigned or the key is empty.
Additional resources: ResourceTable.AddEntry, ResourceTable.GetEntry, IStringEntry
<para>Add plain and Smart String entries to a table.</para>
using Unity.Localization; using UnityEngine;
namespace Unity.Localization.Samples { public class ResourceTableAddStringEntryExample { public void Run() { var shared = ScriptableObject.CreateInstance<SharedTableData>(); var table = ScriptableObject.CreateInstance<ResourceTable>(); table.SharedData = shared; table.LocaleIdentifier = "en";
StringEntry greeting = table.AddStringEntry("Greeting", "Hello"); Debug.Log(greeting.Value); // Hello
table.AddStringEntry("Score", "You scored {0}", isSmart: true); } } }