用户工具

站点工具


侧边栏



Unity3D中文文档

script:unityengine:classes:layermask:layermask

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 可以选择性地过滤物体,例如当投射射线时。

JavaScript:

// 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");
	}
}

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 变量

valueConverts a layer mask value to an integer value.
转换层蒙版的值为整数值。

Static Functions 静态函数

GetMaskGiven 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.
无论是内置的层名称集或是由用户在“标签和层管理器”中定义的层,返回与它们相等的层蒙版。
LayerToNameGiven 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中定义的层名称。
NameToLayerGiven 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 运算符

LayerMaskImplicitly converts an integer to a LayerMask.
隐式转换整数为层蒙版。
script/unityengine/classes/layermask/layermask.txt · 最后更改: 2016/08/02 05:30 (外部编辑)