Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

LocalVariablesGroup

class in Unity.Localization


Implements interfaces:ISerializationCallbackReceiver, IVariableGroup

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

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); } } }

Properties

Property Description
Count The number of variables in the group.

Public 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.