Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PhysicsMask

A 64-bit mask, effectively 64 flags. The default enumerator will iterate all the bits that are set (1).
Read time 2 minutesLast updated 10 days ago

Definition

public struct PhysicsMask : IEnumerable<int>, IEnumerable

Fields

Value

Description

bitMaskA 64-bit mask, effectively 64 flags.

Static Fields

Value

Description

AllAll 64 bits set (1) in the PhysicsMask.
NoneNo bits set in the PhysicsMask, effectively zero.
OneBit #0 set (1) in the PhysicsMask. The remaining bits are reset (0).

Constructors

Constructor

Description

PhysicsMask(System.Int32[])Create a PhysicsMask by specifying multiple bits to set (1).
PhysicsMask(UnityEngine.LayerMask)Create a PhysicsMask from a LayerMask. A LayerMask is only 32-bits wide so the PhysicsMask will have the upper 32-bits set to zero.

Properties

Property

Description

resetBitsGets an enumerable group of bits that are currently reset (0). The bits are returned in ascending bit-index order. This uses PhysicsMask.ResetBitIterator.
setBitsGets an enumerable group of bits that are currently set (1). The bits are returned in ascending bit-index order. This uses PhysicsMask.SetBitIterator.

Methods

Method

Description

AreAnyBitsSetChecks if any of the provided PhysicsMask set bits are also set in this PhysicsMask.
AreBitsSetChecks if all the provided PhysicsMask set bits are also set in this PhysicsMask.
IsBitSetIs the specified bit set.
ResetBitReset (0) the specified bit.
SetBitSet (1) the specified bit.
ToLayerMaskConvert the lower 32-bits of the 64-bit mask to the 32-bit LayerMask. A LayerMask is only 32-bits wide so the upper 32-bits of the PhysicsMask will be ignored.

Classes

Class

Description

PhysicsMask.ShowAsPhysicsMaskAttributeWhen applied to a field/property of type PhysicsMask, the field/property drawer will not be display it as PhysicsLayers. 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).

Structs

Struct

Description

PhysicsMask.ResetBitIteratorAn iterator that will iterate only the bits that are reset (0) in a PhysicsMask
PhysicsMask.SetBitIteratorAn iterator that will iterate only the bits that are set (1) in a PhysicsMask