why is LayerMask different than gameObject.layer. - 256 = 8?

I have LayerMask on 1. user so Layer 8

public LayerMask TrueLayer = 256;
public LayerMask Layer;
void Start(){
	Debug.Log(gameObject.layer); // 8
	Layer.value = gameObject.layer;
	Debug.Log(Layer.value);
}

Problem over here is I get value 8 WTF?!?!?

BUT when I look in inspector I see 2 different Layers:

22427-untitled.jpg

what’s going on?

why is layer not layer?

Men, just use this :

Mathf.Log(collisionlayerMask.value, 2)

It’s that simple (I searched for a while for this so, here it is)
(It’s the logarithm of the number in base 2 → it’s the opposite of the 2^x function)

I don’t comment something often but I was too amazed to see why people struggled so much with bit-twisting…
You’re welcome :slight_smile:

2 ^ 8 = 256

You can currently only have a Game Object associated with a single 1, of the 32 available slots, but other things in Unity can utilize all of the 1s and 0s.

e.g. Unity - Scripting API: Camera.cullingMask