Text color change onHover

Hi,

I’m trying to change the text color of a GUILayout.Box using the onHover text color of my skin but, for some reason, it isn’t working at all.

GUILayout.Box(“text”, GUI.skin.GetStyle(“custom_style”));

Do you know how can I do this?

Thanks in advance,
André

Your code suggests that you've added a custom style named "custom_style" to a GUISkin that has been assigned in your game.

You need to assign your GUISkin in the OnGUI function, which looks something like this:

var myCustomSkin : GUISkin;

function OnGUI() 
{
    GUI.skin = myCustomSkin;
}

Also, onHover only applies to toggle buttons that are in their "on" state. You want to use hover in stead.

Also, if you don't have a background image associated with the hover state, it won't work.

The states that don't have background images are ignored.

You can set the textcolor on the GUIStyleState for the appropriate mode(s) that you need it for (probably onHover in your case). You can do this through the inspector or code.