Wierdness with mouse roll-over script

I’m using this script from the wiki:

var highlightColor = Color.yellow;
	
function OnMouseEnter () {
	guiText.material.color = highlightColor;
}

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

And set it up on my GUItext as shown in the picture. What is weird is that the text only highlights when the mouse rolls over the left side of the text. I tried changing the pixel offset and still happens. Ya think I’ve discovered a bug?

31306--1142--$picture_1_132.png

AHA! Only happens when I set “pixel correct” to “on”. If I turn it off it works fine. Also tried various fonts and no font, same result. Sure looks like a bug to me…

That’s weird, because (you guessed it) it works fine here, pixel correct or otherwise…sure there’s not something blocking it? I don’t know how you’d block GUItext but maybe there’s a way. :slight_smile:

–Eric

I created a new project and tried it and it worked fine. I re-opened my troubled project, turned off everything I could think of that might be causing the problem and the weirdness still happens. Only thing I can think of that may be causing the problem is that I’m using 3 cameras, filling portions of the screen and am using lots of GUItext. It’s an experimental scene that I’m experimenting with different things in. Everything’s been working pretty well so far (well I did crash Unity once :? ) but otherwise everything seems OK. I’m thinking the bug may be because I maybe approaching Unity’s limits for GUItext elements…

Hmm…a little experimenting with a couple of cameras and GUITextures did show me that it’s possible to get some inconsistent results when you have stuff overlapping. For example, having a GUITexture overlapping some GUIText causes the GUIText highlighting to work normally in one camera, but the GUITexture blocks some of the GUIText from responding to the highlighting in the other camera. That’s with pixel correct off…with it on, I get some blocking with both cameras, but in different ways.

Interesting, and possibly a bug or maybe the result of undefined behavior, but maybe if you put any problematic GUITextures that might be blocking stuff on the “ignore raycast” layer, that might sort everything out…or not, if turning them off didn’t work either. I doubt there’s a limit to the GUI elements, or if there is, it’s probably the same as the limit for the number of levels (i.e., 2^31).

–Eric

You probably want to specifically set the depth of the gui element by changing the z coordinate of the transform. This way, the gui elements will be guaranteed to be in the order you intended them to be. If the z coordinate for the two gui elements is the same, their rendering order is random.

Yes, this was the first thing I thought might be happening, so my GUItext is all at Z=1 while my GUItextures are at Z=0. This had no effect.