var layer : int
Description描述
The layer the game object is in. A layer is in the range [0...32]
Layers can be used for selective rendering from cameras or ignoring raycasts.
游戏物体所在的层,一个层的范围是在[0...32]之间。
层可以用于摄像机的选择性渲染或者忽略光线投射。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public void Awake() {
gameObject.layer = 2;
}
}
//把游戏物体放到忽略光线投射层
gameObject.layer = 2;