Mouse never leaves Collider

I have a Textmesh with a boxcollider on it which is sized just fine. When my mouse enters the collider, the OnMouseEnter() and the OnMouseOver() methods begin to execute. Nothing wrong there. OnMouseDown() also works perfectly. The only problem that I have is when my mouse goes to leave the collider area. The script never realizes that the mouse actually leaves. I tested this with a little code like so:

    public bool isSelected = false;
    TextMesh myText;

    void Start()
    {
        myText = gameObject.GetComponent<TextMesh>();
    }

    void OnMouseEnter()
    {
        isSelected = true;
    }

    void OnMouseDown()
    {
        Application.LoadLevelAdditive("");
        print("Click");
    }

    void Update()
    {
        if (isSelected)
            myText.color = Color.yellow;
        else
            myText.color = Color.white;

        isSelected = false;
    }

When the mouse enters the collider, isSelected becomes true and the color of the text changes to Yellow, so I know that part works, but with it on OnMouseEnter(), I can check the status of the mouse entering every frame (I know that it should be OnMouseOver() later, this is for debug purposes.) Now,on the second frame after the mouse enters the collider, it changes to the color to White because the isSelected variable is set to false now. Great, works fine.

When the mouse supposedly leaves the collider, and reenters, the OnMouseEnter() method doesn’t fire because it thinks the mouse is still in the collider for some weird reason. Any suggestions as to why this might be, and potential fixes?

P.S. I can get the OnMouseExit() function to work properly on another script in a different scene.

The way you have things structured right now, the first frame after you set ‘isSelected’ to ‘true’, the Update() function turns the text yellow. But since you set ‘isSelected’ to ‘false’ in the Update() loop, the text goes back to white the very next frame. Why not so something like this instead:

TextMesh myText;

void Start()
{
	myText = gameObject.GetComponent<TextMesh>();
}

void OnMouseEnter()
{
	myText.color = Color.yellow;
}

void OnMouseExit()
{
	myText.color = Color.white;
}

void OnMouseDown()
{
	Application.LoadLevelAdditive("");
	print("Click");
}

Interesting observation and answer to my question.

OnMouseExit() does not occur until the mouse enters a new collider different from the one which it is currently in.

So, to solve this problem, you have to have a collider besides the one with the OnMouseEnter()/OnMouseOver(), and mouse over that collider for the OnMouseExit() method to actually occur.

Not sure if this is how Unity intended for it to work, but this is the solution for now at least.