Version: 2017.1
public static int NameToLayer (string layerName);

描述

给定层名称,返回在 Tags and Layers manager 中由 Builtin 或 User Layer 定义的层索引。

using UnityEngine;
using System.Collections;

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