Isolate UI elements from 3D scene

Isolate UI elements from 3D scene

this might seem like a silly question but I'm raycasting on specific objects (Targets) in a scene and zooming in on them but i also have a few UI elements (buttons, toggles...) on the side of the screen that need to always be visible because they provide certain functionalities (isolate target, switch view...).  
The problem is that sometimes when i want to click on a certain UI element I unintentionally send a Raycast that changes my target. Moving the UI elements is not helpful since the objects occupy the whole screen. What other ways do I have to make sure I'm only clicking the UI element? (especially for smaller screens)

Solutions/Answers:

Answer 1:

You can query EventSystem.Current.IsPointerOverGameObject() to check whether the mouse cursor is over a UI object associated with the EventSystem.

If it is, then you can refrain from firing your raycast, on the assumption that the player is trying to click the button, not select the 3D world behind the button.

References