Hydrogen Framework  1.3.1
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Hydrogen.Layers Class Reference

Additional static functions used to extend existing Layers support inside of Unity. More...

Static Public Member Functions

static bool ContainsLayer (this LayerMask layerMask, int targetLayer)
 Does the layerMask contain the specified layer? More...
 
static int EverythingBut (params int[] layers)
 Create a layer mask of everything but these layers. More...
 
static bool IsInLayerMask (this GameObject obj, LayerMask layerMask)
 Checks if a GameObject is in a LayerMask. More...
 
static int OnlyIncluding (params int[] layers)
 Create a layer mask only including these layers. More...
 

Detailed Description

Additional static functions used to extend existing Layers support inside of Unity.

Definition at line 38 of file Layers.cs.

Member Function Documentation

static bool Hydrogen.Layers.ContainsLayer ( this LayerMask  layerMask,
int  targetLayer 
)
static

Does the layerMask contain the specified layer?

Returns
true, if the layer is contained, false otherwise.
Parameters
layerMaskThe LayerMask to poll
targetLayerThe layer to check.

Definition at line 46 of file Layers.cs.

47  {
48  return (layerMask.value & 1 << targetLayer) != 0;
49  }
static int Hydrogen.Layers.EverythingBut ( params int[]  layers)
static

Create a layer mask of everything but these layers.

Returns
A layer mask of everything but the passed layers.
Parameters
layersArray of Layer IDs.

Definition at line 56 of file Layers.cs.

57  {
58  return ~OnlyIncluding (layers);
59  }
static int OnlyIncluding(params int[] layers)
Create a layer mask only including these layers.
Definition: Layers.cs:79
static bool Hydrogen.Layers.IsInLayerMask ( this GameObject  obj,
LayerMask  layerMask 
)
static

Checks if a GameObject is in a LayerMask.

Parameters
objGameObject to test
layerMaskLayerMask with all the layers to test against
Returns
True if in any of the layers in the LayerMask

Definition at line 67 of file Layers.cs.

68  {
69  // Convert the object's layer to a bitfield for comparison
70  int objLayerMask = (1 << obj.layer);
71  return (layerMask.value & objLayerMask) > 0;
72  }
static int Hydrogen.Layers.OnlyIncluding ( params int[]  layers)
static

Create a layer mask only including these layers.

Returns
A layer mask including only the passed layers.
Parameters
layersArray of Layer IDs

Definition at line 79 of file Layers.cs.

80  {
81  int mask = 0;
82  foreach (int item in layers) {
83  mask |= 1 << item;
84  }
85  return mask;
86  }