# PhysicsMask

> A 64-bit mask, effectively 64 flags. The default enumerator will iterate all the bits that are set (1).

## Definition

* **Type:** Struct
* **Namespace:** [UnityEngine.LowLevelPhysics2D](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d.md)
* **Assembly:** UnityEngine.Physics2DModule
* **Implements:** [IEnumerable\<int>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable)

```csharp
public struct PhysicsMask : IEnumerable<int>, IEnumerable
```

## Fields

| Value                                                                                           | Description                          |
| ----------------------------------------------------------------------------------------------- | ------------------------------------ |
| [bitMask](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/bitmask.md) | A 64-bit mask, effectively 64 flags. |

## Static Fields

| Value                                                                                     | Description                                                          |
| ----------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| [All](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/all.md)   | All 64 bits set (1) in the PhysicsMask.                              |
| [None](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/none.md) | No bits set in the PhysicsMask, effectively zero.                    |
| [One](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/one.md)   | Bit #0 set (1) in the PhysicsMask. The remaining bits are reset (0). |

## Constructors

| Constructor                                                                                                                                      | Description                                                                                                                                                                                     |
| ------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [PhysicsMask(System.Int32\[\])](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/ctor.md#physicsmask\(int\))            | Create a PhysicsMask by specifying multiple bits to set (1).                                                                                                                                    |
| [PhysicsMask(UnityEngine.LayerMask)](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/ctor.md#physicsmask\(layermask\)) | Create a PhysicsMask from a LayerMask. A [LayerMask](/engine/6000.3/script-reference/unityengine/layermask.md) is only 32-bits wide so the PhysicsMask will have the upper 32-bits set to zero. |

## Properties

| Property                                                                                            | Description                                                                                                                                                                                                                                                 |
| --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [resetBits](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/resetbits.md) | Gets an enumerable group of bits that are currently reset (0). The bits are returned in ascending bit-index order. This uses [PhysicsMask.ResetBitIterator](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/resetbititerator.md). |
| [setBits](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/setbits.md)     | Gets an enumerable group of bits that are currently set (1). The bits are returned in ascending bit-index order. This uses [PhysicsMask.SetBitIterator](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/setbititerator.md).       |

## Methods

| Method                                                                                                      | Description                                                                                                                                                                                                                                                                             |
| ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AreAnyBitsSet](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/areanybitsset.md) | Checks if any of the provided PhysicsMask set bits are also set in this PhysicsMask.                                                                                                                                                                                                    |
| [AreBitsSet](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/arebitsset.md)       | Checks if all the provided PhysicsMask set bits are also set in this PhysicsMask.                                                                                                                                                                                                       |
| [IsBitSet](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/isbitset.md)           | Is the specified bit set.                                                                                                                                                                                                                                                               |
| [ResetBit](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/resetbit.md)           | Reset (0) the specified bit.                                                                                                                                                                                                                                                            |
| [SetBit](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/setbit.md)               | Set (1) the specified bit.                                                                                                                                                                                                                                                              |
| [ToLayerMask](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/tolayermask.md)     | Convert the lower 32-bits of the 64-bit mask to the 32-bit [LayerMask](/engine/6000.3/script-reference/unityengine/layermask.md). A [LayerMask](/engine/6000.3/script-reference/unityengine/layermask.md) is only 32-bits wide so the upper 32-bits of the PhysicsMask will be ignored. |

## Classes

| Class                                                                                                                                             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [PhysicsMask.ShowAsPhysicsMaskAttribute](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/showasphysicsmaskattribute.md) | When applied to a field/property of type [PhysicsMask](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask.md), the field/property drawer will not be display it as [PhysicsLayers](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicslayers.md). Instead, the field/property will be displayed as bit numbers only i.e. a raw 64-bit mask allowing each bit to be (de)selected. This is only used when full layer editing is active (see [PhysicsLowLevelSettings2D.useFullLayers](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicslowlevelsettings2d/usefulllayers.md)). |

## Structs

| Struct                                                                                                                        | Description                                                                                                                                                     |
| ----------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [PhysicsMask.ResetBitIterator](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/resetbititerator.md) | An iterator that will iterate only the bits that are reset (0) in a [PhysicsMask](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask.md) |
| [PhysicsMask.SetBitIterator](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask/setbititerator.md)     | An iterator that will iterate only the bits that are set (1) in a [PhysicsMask](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsmask.md)   |
