Legacy Documentation: Version 2017.2 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

LayerMask.NameToLayer

public static int NameToLayer(string layerName);

Description

Given a layer name, returns the layer index as defined by either a Builtin or a User Layer in the Tags and Layers manager.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Example() { Debug.Log(LayerMask.NameToLayer("TransparentFX")); } }

Did you find this page useful? Please give it a rating: