Collider OnMouseEnter VS Raycast

Hello!
I’m trying to display a context window when hovering certain objects which have a BoxCollider.
image

I first tried to implement it by adding OnMousEnter in a script attached to the gameobject which also have the Collider, but it’s somehow not triggered:

internal void OnMouseEnter()
{
      Debug.Log("Entered " + StarData.ProperName);
      GameBoardManager.Instance.ShowStarInfo(StarData);
}

So instead, in the manager’s Update loop, I added a raycast

Vector3 mousePos = Input.mousePosition;
var ray = Camera.main.ScreenPointToRay(mousePos);
if (Physics.Raycast(ray, out var hit))
{
    Debug.Log(hit.collider.gameObject.name);
    if (hit.collider.gameObject.TryGetComponent(out UIStarController starController))
    {
        ShowStarInfo(starController.StarData);
    }
    else
    {
        ShowStarInfo(null);
    }
}

And it does work (ish, it’s inefficient at the moment since it’s more an equivalent to a OnHover, triggering the Show method every single update)

So,

  1. How can I debug the OnMouseEnter not working?
  2. Is it even worth it? I mean is the Raycast going on every update going to be much more inefficient once I have fixed the constant update?

Is it possible that you have something in front of the object that is blocking the mouse? Like some sort of transparent UI element?

@dstrears yeah after checking, I sort of do, I have a full screen canvas, BUT no panel is displayed over the gameobjects. Deactivating the whole UI by disabling the canvas doesn't fix it.

Take a look at this thread: https://forum.unity.com/threads/onmouseenter-not-working-solved-kinda.377550/ I had to switch the "Active Input Handling" to both in the project settings

Thanks. I'm using the Old Input Manager, so that's not it. I've narrowed it down to a layer issue. It used to work on a different type of objects, but now it only works in a specific layer for these objects as well. I still don't understand what could be capturing the input though, as it doesn't work when the UI is deactivated. It's not a big deal, I made it work using raycasts, I just like to understand things... As a note, the doc seems to be wrong on the need to have the Collider set as Trigger for it to work.