class in Unity.Localization
Implements interfaces:ISerializationCallbackReceiver, IVariableGroup
A named collection of Smart String variables owned by a localized string.
A LocalVariablesGroup implements IVariableGroup to hold the local IVariables
that a LocalizedString formats against. Smart String placeholders such as {score} look up values in
this group during formatting. Variables are stored polymorphically through [SerializeReference], so a scalar, an
object, or a nested LocalizedString can all be added. Names are unique and whitespace-normalized:
LocalVariablesGroup.Add returns the name a variable was actually stored under.
Additional resources: LocalizedString, IVariable
<para>Add a variable and check that it exists.</para>
using Unity.Localization; using UnityEngine;
namespace Unity.Localization.Samples { public class LocalVariablesGroupOverviewExample { public void AddAndCheck() { var localizedString = new LocalizedString(); var group = localizedString.LocalVariables; var name = group.Add(new LocalizedString(), "subtitle"); bool present = group.ContainsName(name); Debug.Log(present); } } }
| Property | Description |
|---|---|
| Count | The number of variables in the group. |
| Method | Description |
|---|---|
| Add | Adds a variable under a unique, whitespace-normalized name and returns that name. |
| Clear | Removes every variable from the group. |
| ContainsName | Determines whether a variable is stored under the given name. |
| Remove | Removes the variable stored under the given name. |