Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ContainsName(string)

Determines whether a variable is stored under the given name.
Read time 1 minuteLast updated 12 days ago

Definition

  • Type: Method
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule
public bool ContainsName(string name)

Parameters

name

The variable name to look for.

Returns

Type

Description

bool
true
when a variable is stored under the name; otherwise,
false
.

Remarks

Lookup is case-sensitive and matches the whitespace-normalized name assigned by LocalVariablesGroup.Add.
Check whether a variable exists before using it.

Examples

using Unity.Localization;using Unity.SmartStrings.PersistentVariables;using UnityEngine;namespace Unity.Localization.Samples{ public class LocalVariablesGroupContainsNameExample { public void Check() { var group = new LocalVariablesGroup(); group.Add(new IntVariable { Value = 5 }, "score"); if (group.ContainsName("score")) Debug.Log("Score variable is set."); } }}