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

LocalVariablesGroup.Add

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

Declaration

public string Add(IVariable variable, string name);

Parameters

Parameter Description
variable The variable to store in the group.
name A preferred name for the variable, or null to use the default.

Returns

string The unique name that the variable was stored under.

Description

Adds a variable under a unique, whitespace-normalized name and returns that name.

The requested name is normalized by replacing whitespace with hyphens, then made unique by appending a numeric suffix when needed (for example, variable, then variable-2). When no name is given, it defaults to variable. The returned name is the one the variable is actually stored under.

<para>Add a variable and keep the name it was stored under.</para>

using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples { public class LocalVariablesGroupAddExample { public void Add() { var group = new LocalVariablesGroup(); var name = group.Add(new LocalizedString(), "subtitle"); Debug.Log(name); } } }