LayerMask 层蒙版
struct in UnityEngine
Description 描述
LayerMask allow you to display the LayerMask popup menu in the inspector.
layermask允许你在检视面板中显示layermask弹出菜单。
Similar to those in the camera.cullingMask. Layer masks can be used selectively filter game objects for example when casting rays.
类似与camera.cullingmask。layermask 可以选择性地过滤物体,例如当投射射线时。
C#:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public LayerMask mask = -1;
void Update() {
if (Physics.Raycast(transform.position, transform.forward, 100, mask.value))
Debug.Log("Hit something");
}
}
Variables 变量
value | Converts a layer mask value to an integer value. 转换层蒙版的值为整数值。 |
Static Functions 静态函数
GetMask | Given a set of layer names as defined by either a Builtin or a User Layer in the Tags and Layers manager, returns the equivalent layer mask for all of them. 无论是内置的层名称集或是由用户在“标签和层管理器”中定义的层,返回与它们相等的层蒙版。 |
LayerToName | Given a layer number, returns the name of the layer as defined in either a Builtin or a User Layer in the Tags and Layers manager. 给定一个层数,返回内置的或在Tags and Layers中定义的层名称。 |
NameToLayer | Given a layer name, returns the layer index as defined by either a Builtin or a User Layer in the Tags and Layers manager. 给定一个层名称,返回内置的或在Tags and Layers manager中定义的层索引。 |
Operators 运算符
LayerMask | Implicitly converts an integer to a LayerMask. 隐式转换整数为层蒙版。 |