public int layer ;

Description

该游戏对象所在的层。

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; } }