LocalVariablesGroup
A named collection of Smart String variables owned by a localized string.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Class
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
- Implements: IVariableGroup, ISerializationCallbackReceiver
public class LocalVariablesGroup : IVariableGroup, ISerializationCallbackReceiver
Remarks
A LocalVariablesGroup implements IVariableGroup to hold the local IVariables that a LocalizedString formats against. Smart String placeholders such as look up values in this group during formatting. Variables are stored polymorphically through , 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.
{score}[SerializeReference]Additional Resources: LocalizedString, IVariable
Add a variable and check that it exists.
Examples
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); } }}
Properties
Property | Description |
|---|---|
| Count | The number of variables in the group. |
Methods
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. |