forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLayerMask.bindings.cs
More file actions
67 lines (57 loc) · 2.27 KB
/
Copy pathLayerMask.bindings.cs
File metadata and controls
67 lines (57 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using UnityEngine.Bindings;
using UnityEngine.Scripting;
namespace UnityEngine
{
// LayerMask allow you to display the LayerMask popup menu in the inspector
[RequiredByNativeCode(Optional = true, GenerateProxy = true)]
[NativeHeader("Runtime/BaseClasses/BitField.h")]
[NativeHeader("Runtime/BaseClasses/TagManager.h")]
[NativeClass("BitField", "struct BitField;")]
public struct LayerMask
{
[NativeName("m_Bits")]
private int m_Mask;
public static implicit operator int(LayerMask mask)
{
return mask.m_Mask;
}
// implicitly converts an integer to a LayerMask
public static implicit operator LayerMask(int intVal)
{
LayerMask mask;
mask.m_Mask = intVal;
return mask;
}
// Converts a layer mask value to an integer value.
public int value
{
get { return m_Mask; }
set { m_Mask = value; }
}
// Given a layer number, returns the name of the layer as defined in either a Builtin or a User Layer in the [[wiki:class-TagManager|Tag Manager]]
[StaticAccessor("GetTagManager()", StaticAccessorType.Dot)]
[NativeMethod("LayerToString")]
extern public static string LayerToName(int layer);
// Given a layer name, returns the layer index as defined by either a Builtin or a User Layer in the [[wiki:class-TagManager|Tag Manager]]
[StaticAccessor("GetTagManager()", StaticAccessorType.Dot)]
[NativeMethod("StringToLayer")]
extern public static int NameToLayer(string layerName);
// Given a set of layer names, returns the equivalent layer mask for all of them.
public static int GetMask(params string[] layerNames)
{
if (layerNames == null) throw new ArgumentNullException("layerNames");
int mask = 0;
foreach (string name in layerNames)
{
int layer = NameToLayer(name);
if (layer != -1)
mask |= 1 << layer;
}
return mask;
}
}
}