AddStringEntry(string, string, bool?)
Adds or updates a plain string entry for a key.
Read time 1 minuteLast updated 9 days ago
Definition
- Type: Method
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
public StringEntry AddStringEntry(string key, string value, bool? isSmart = null)
Parameters
Returns
Type | Description |
|---|---|
| StringEntry | The added or updated entry, or |
Remarks
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 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 when no shared data is assigned or the key is empty.
isSmartnullAdd plain and Smart String entries to a table.
Examples
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); } }}