LayerMask 层蒙版

Struct

LayerMask allow you to display the LayerMask popup menu in the inspector

similar to those in the camera.cullingMask. Layer masks can be used selectively filter game objects for example when casting rays.

layermask允许你在检视面板中显示layermask弹出菜单,类似与camera.cullingmask。layermask 可以选择性地过滤物体,例如当投射射线时

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public LayerMask mask = -1;
	void Update() {
		if (Physics.Raycast(transform.position, transform.forward, 100, mask.value))
			Debug.Log("Hit something");

	}
}
// Casts a ray using the layer mask,
// which can be modified in the inspector.
//使用层蒙板投射一条射线
//它可以在检视面板中修改

var mask : LayerMask = -1;
function Update () {
	if (Physics.Raycast (transform.position, transform.forward, 100, mask.value)) {
		Debug.Log("Hit something");
	}
}

Variables变量

Class Functions类函数

Page last updated: 2011-2-24