Make mask layer have priority over other mask layer on raycast

Hi, I would like to know if there is a way to make raycast hit a layer with more priority than other layer.

I have two layers which I can click on them, but I want to raycast on one layer before another one, so is there a way o I have to use raycastAll and then check all elements and code the priority myself. I was hoping with the order in the layer editor the raycast check one layer before another one but it doesn’t.

I hope I was clear enough.

Thanks!

The only way I can think of doing this is by having two separate raycasts. I can see how the term "layer’ is a bit misleading in this scenario, but as you mentioned, the order has no bearing on how a raycast works (when doing RaycastAll in this manner).