Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


LocalVariablesGroup

A named collection of Smart String variables owned by a localized string.
Read time 1 minuteLast updated 6 days ago

Definition

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

CountThe number of variables in the group.

Methods

Method

Description

AddAdds a variable under a unique, whitespace-normalized name and returns that name.
ClearRemoves every variable from the group.
ContainsNameDetermines whether a variable is stored under the given name.
RemoveRemoves the variable stored under the given name.