OnMouseEnter Confusion

I have a script which changes the text color of a GUI Text when the mouse enters and exits (full script)

var normalColor = Color.white;
var hoverColor = Color.white;
var pressedColor = Color.white;
var message = "Message to send";

private var isPressed = false;

function Awake ()
{
	guiText.material.color = normalColor;	
}

function OnMouseEnter ()
{
	if (isPressed)
		guiText.material.color = pressedColor;
	else
		guiText.material.color = hoverColor;
}

function OnMouseExit ()
{
	guiText.material.color = normalColor;
}

function OnMouseUp ()
{
	isPressed = false;

	if (guiElement.HitTest(Input.mousePosition))
	{
		var controller : GameController = FindObjectOfType(GameController);
		controller.SendMessage(message);
	}
}

function OnMouseDown ()
{
	isPressed = true;

	guiText.material.color = pressedColor;
}

The confusion is that this script is attached to three seperate GUI Text objects and works correctly in the “Game View” screen. But when I do “Build And Run”, the 1st object doesn’t highlight if you mouse over it. But if you mouse over the third object, the first object highlights as well. However the button actions work correctly (OnMouseUp sends the correct message). Anyone have any idea what’s going on? I’ve changed the script and saved after already attaching it to a GUI Text, would that affect it? I just don’t know why it works in the preview but in the compiled game it’s different.

Maybe if you duplicated yr script so you have 3 identical w different names and applied 1 to each button?
AC

I can’t recreate your problem :frowning: Your script works perfectly for me in both the Game view and when I build a web player and an OS X PPC stand alone.

Hmm, tried removing the scripts from the text objects and created 2 new scripts with the same text. Saved them as TextButton, TextButton2, TextButton3 and added a seperate script to each object. Game View still shows ok, but Build and Run now highlights when hovering over the first and also highlights the second. And now the second doesn’t highlight, but the third is normal. I even tried doing different builds.

Thanks for testing. I tried Universal, Web Player, and Intel and they all do the same thing. Must be some problem with my scene file or the objects. I’ll just recreate them and see if it helps.

Tried creating a new project… same issue. Tried using a prefab… same issue. I’m guessing this might be a bug? It runs perfectly in the “Game View”. Suppose I’ll submit a bug report.

Is it possible you have an issue similar to this one?

:shock:

Could very well be. I have a Radeon X1900. Of course I’m not really shocked that an ATI card has OpenGL problems and I’ve always wondered why Apple uses their cards (though Apple does write the drivers). I wish Apple would be quicker at fixing these driver bugs (I’ve had driver bugs in a different game engine with problems on framebuffer objects).