Full Screen GUI.Box prevents OnMouseEnter() or OnMouseExit()

If I have the following line:

GUI.Box(Rect.MinMaxRect(0.0f, 0.0f, Screen.width, Screen.height),new GUIContent(GUIFullGraphic));

Notice that this box covers the entire range of pixels on the screen.

Any Object in the scene that has OnMouseEnter() or OnMouseExit() functions do not process these functions unless a mouse input button is pressed.

These are the functions that stop processing when I have the above GUI.Box drawn.

    void OnMouseEnter()
    {
        print(transform.GetInstanceID() + "; On Mouse Enter");
        MouseOver = true;
        renderer.material.color = Color.red;
    }
    void OnMouseExit()
    {
        print(transform.GetInstanceID() + "; On Mouse Exit");
        MouseOver = false;
        renderer.material.color = Color.white;

    }

if I then press one of the mouse input buttons the OnMouseEnter() and OnMouseExit functions do process for 1 frame. If I continue to hold down the mouse button, the events will not fire again until I release the input and press it down again.

The reason I am using a GUI.Box that fills the entire screen is to display a masking texture to overlay the scene. (the GUI.Box background color is set to completely transparent).

This appears to be a bug, unless the GUI.Box was never designed to cover the entire screen and still receive input events from objects in the scene. Is there an alternate way to display a full screen transparent mask image that won’t affect the OnMouseEnter and OnMouseExit events?

Does GUI.DrawTexture do what you need?

The simplest is often to use GUI.Label instead of GUI.Box - that only draws and does not intercept mouse events.

GUI.DrawTexture does seem to fix the problem! thanks for the quick response.

If it can be of any help to someone, I too encountered this issue and worked around it by using a GUI.Label instead with the same GUIStyle.

It seems like this control doesn’t affect the mouse event system.

GUI.DrawTexture couldn’t have done the trick because I had to draw a large box frame without scaling the borders of the small source image (hence using the RectOffset ‘border’ attribute of GUIStyle).