OnMouseExit and OnGUI conflict

I have a gameObject with a script attached on it which fires OnMouseExit (though it should not) every frame while :

  • left mouse button is pressed
  • mouse moves while STILL on rollOver on the gameObject.

Here the way to reproduce

  • create a new scene
  • put a cube primitive on the scene
  • try to make it big enough on the game screen so it’s easy to move the mouse cursor and staying over the cube
  • now make 2 scripts :
    One with : function OnMouseExit(){Debug.Log(“exit!”) ;} and attached it to the cube
    One with : function OnGUI(){} ; and attached it to the MainCamera (yeah i know there is nothing in the OnGUI callback)

Now play the scene and while you are over the cube press left mouse button and move the mouse while you are staying over the cube. You’ll see many “exit!” in the console.

If you remove the script from the mainCamera and play the scene again, there is no more issue…

I’m on Unity pro 2.6.1, hope it is (or it will be) fixed in Unity 3.0 ^^

Hi, welcome to the forum!

This bug was logged some time ago and is fixed in 3.0 (I’ve just tested it to be sure). However, please let us know if you see any recurrence of it.