Hello, I am building the menu system for a game I am making. I am trying to setup a Rect that will turn off raycasting when the mouse is over it. This will keep clicks in the menu from passing raycasts through to the scene.
//Create a Rect to act as a Mask for the mouse.
raycastMask = new Rect(mainMenuLeftAnchor,Screen.height - mainMenuSizeY,mainMenuSizeX + buttonBarSizeX,mainMenuSizeY);
// Set a bool to true if the mask contains the mouse.
raycastAllowed = raycastMask.Contains(Input.mousePosition);
//Pass that bool to the camera to disable/enable raycasts.
spaceCamera.SetRaycasting(raycastAllowed);
Since the Rect may have been in Screen coordinates I have defined the Rect this way also:
Rect(mainMenuLeftAnchor,mainMenuSizeY,mainMenuSizeX + buttonBarSizeX,mainMenuSizeY);
The odd thing to me is that both Rects are placed in the top left of the screen.
Here is a visual:
Any help is appreciated!