Version: 2019.4
public int layer ;

説明

The layer the game object is in.

Layers can be used for selective rendering from cameras or ignoring raycasts. Unity generates 32 layers. Layers from 8 and above are unused. They can be used for specific game reasons. Layers are named and used during the development of the game. Layers are added and viewed by clicking the top-right editor Layout button.

// Put the game object in the ignore raycast layer (2)

using UnityEngine; using System.Collections;

public class ExampleClass : MonoBehaviour { void Example() { gameObject.layer = 2; } }