Consider the following code existing in the update function of a script attached to camera:
float zoom = Input.GetAxis("Mouse ScrollWheel");
if (zoom != 0) {
translation.y -= zoom * zoomSpeed;
}
Just your basic run of the mill input handling for mouse wheel input; which I use for zooming.
This breaks down though when I start adding UI menus. I have a menu (Panel) with some scrollable content. When I hover over the UI, I want to disable the mouse wheel zoom on the camera.
I tried doing this:
if (!EventSystem.current.IsPointerOverGameObject()) {
float zoom = Input.GetAxis("Mouse ScrollWheel");
if (zoom != 0) {
translation.y -= zoom * zoomSpeed;
}
}
But this disables the mousewheel if I am hovering over ANY gameobject. How can I test to see if I am hovering over a UI related gameobject?