Prevent raycast to OnMouseOver() or OnMouseEnter() when mouse over UI

As title says, it there anyway how to prevent Unity firing OnMouseOver() or OnMouseEnter() functions when mouse is over 4.6 UI objects?

Note, this cannot be stopped with UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject() since Unity handles calls to those functions.

Around the code you are processing the raycast do an if statement to check a bool which monitors whether the mouse is over the UI element. If you know how to use event systems, you should be fine, but if your not, here is a start:

public class RaycastingScript : MonoBehaviour {
       
       public bool hovering = false;
       
       public void OnEnter () {
              hovering = false;
       }
       
       public void OnExit () {
              hovering = true;
       }
       
       void Update () {
              if (hovering) {
                     if (physics.raycast(...)) {
                            //INSERT RAYCAST CODE HERE
                            (. . .)
                     }
              }
       }
}