123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using UnityEngine;
- namespace FirstGearGames.Utilities.Objects
- {
- public static class Layers
- {
-
-
-
-
-
- public static int LayerMaskToLayerNumber(LayerMask mask)
- {
- return LayerValueToLayerNumber(mask.value);
- }
-
-
-
-
-
- public static int LayerValueToLayerNumber(int bitmask)
- {
- int result = bitmask > 0 ? 0 : 31;
- while (bitmask > 1)
- {
- bitmask = bitmask >> 1;
- result++;
- }
- return result;
- }
-
-
-
-
-
-
- public static bool ContainsLayer(LayerMask layerMask, int layer)
- {
- return (layerMask == (layerMask | (1 << layer)));
- }
- }
- }
|