Making GameObjects respond to OnMouseOver(), but not to Raycasts

I am making a game where objects have to do something when they are moused over, however, those same objects have to also be ignored by raycasts. I tried to use the “Ignore Raycasts” layer, but this made OnMouseOver() unresponsive. Any help?,I am making a game in which objects have to perform an action when they are moused over. However, i want those same objects to be ignored by raycasts. I tried to use the Ignore Raycasts layer, but this just made OnMouseOver() not work. Any help?

You can use raycasts, just use a layer mask. See the docs. Project the ray from the camera’s position towards the mouse position in world space using this.