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变量
-
Converts a layer mask value to an integer value.
转换一个层蒙版值到一个整数值。
Class Functions类函数
-
implicitly converts an integer to a LayerMask
隐式转化一个整数到一个层蒙板。 -
Given a layer number, returns the name of the layer as defined in either a Builtin or a User Layer in the Tag Manager
给定一个层数,返回内置的或在tag Maneger中定义的层名称。 -
Given a layer name, returns the layer index as defined by either a Builtin or a User Layer in the Tag Manager
给定一个层名称。返回内置的或在tag Maneger中定义的层索引。
最后修改:2011年2月24日 Thursday 16:26