I've tried quite a few things, but none of them have worked reliably. Here is what I'm currently using:
float scrollInput = Input.GetAxis("Mouse ScrollWheel");
// Check if the mouse is over a UI GameObject with the tag "BlockZoom"
if (EventSystem.current.IsPointerOverGameObject()) {
GameObject go = EventSystem.current.currentSelectedGameObject;
if (go != null && go.tag == "BlockZoom") {
// If the mouse is over a UI GameObject with the "BlockZoom" tag, then don't zoom the camera.
scrollInput = 0f;
}
}
It works sometimes. But obviously, I'm not "selecting" an object.
So is there a way to do this? Keep in mind these are UI elements in screenspace.