- Home /
Ignore clicks on all layers except one
My complete stage is clickable, and I'd like to keep it that way. It's clickable on the background image and works fine.
Now I'd like all the overlaying graphic elements to be ignored when clicking said background.
I know it has something to do with layering and my Graphics raycast on my Canvas. But I'm not quite sure how to properly use it.
Can anyone help me make every layer non-clickable except for the Background layer? (preferably via Unity itself, not script)
Use a Layermask.
//Say you wanted to test against layer 10
var layerNumber : int = 10;
var my$$anonymous$$ask : int = 1 << layerNumber;
Enter my$$anonymous$$ask as the final entry in the Raycast.
Entering "10" into the Layermask entry will not work. The expected value would be 2^10 = 1024
I'm working with a graphics raycaster. What would be the blocking mask and what would be the block object?
Apologies, I overlooked Graphics Raycast. I am not so familiar with that. Cant find layermask anywhere in it :P
Docs are also broken on it.
Fixed it by making a second canvas. Put all static UI elements on that one, give it order: 1 and remove the raycaster.
Your answer
Follow this Question
Related Questions
Ignoring an object (using raycast with layers) is not working 1 Answer
Set transform layer 1 Answer
Raycast ignoring layers that it should not 2 Answers
Can't Ignore a Layer when raycat 0 Answers
Raycast doesnt hit ground 2 Answers