Urgent:GUI Button text color doesn't change for Hover state

Hi,

Defined a custom style named “mainMenuBtnSkin” for button and using it in this way:

GUI.Button(Rect(55, 55, 155, 155), “SINGLE PLAYER”, _mainMenuGUISkin.GetStyle(“mainMenuBtnSkin”));

When texture is applied for Normal Hover state, we could see Normal text color on the GUI button, but text color doesn’t change for HOver state. Would be very thankful if I could get solution to it.

Thanks in advance.

Puzzling… are you definitely sure you have set the normal/hover colours for the button control (and not, say, the box)? I’ll have to think if there is anything else that could cause this problem.

Is your style really called “mainMenuBtnSkin”, or is that the name of your skin, and you changed the content in the Button style of that skin? Perhaps you want:

GUI.Button(Rect(55, 55, 155, 155), "SINGLE PLAYER", _mainMenuGUISkin.GetStyle("Button"));

or even:

GUI.skin = mainMenuGUISkin;
GUI.Button(Rect(55, 55, 155, 155), "SINGLE PLAYER");

(Edit: typically states not showing is because a state’s values are ignored if the corresponding background texture is not set; that was my first thought but you mentioned that both were set)

Hi,

Problem solved, thanks

I used custom style and defined it to button, that has created a problem.
Now I setted Mouse Normal and Hover directly to button style in mainmenuGUIstyle. That is working great. Thanks.

I am having the same problem. Can you elaborate on your explanation?

I am defining a GUIStyle just before I declare the button.

Cheers

Just like Molix

To make the button change with hover or active use GUISkin.

1.Create a GUISkin in your project.
2.Create a var name of skin : GUISkin;
3.In "function OnGUI(){ Place GUI.skin = name of skin;
4.In the inspector assign the skin to the script.
5.Change the skin as you please.

Example:

var MySkin:GUISkin

function OnGUI(){

GUI.skin = MySkin

GUI.Button(Rect(55, 55, 155, 155), “TEXT”);

}

I had the same problem even after ensuring that my skin was properly setup. The issue was with the text changing colour on different states ONLY in styles that were “text-only” and had no graphic associated with it.

Easy Solution: attach a small square clear PNG (I don’t think size matters) as the background texture to each of your states for text-only buttons. Somebody told me once that the default for text-only GUIstyles ignores colour changes in case it is being used as a label or regular text.

That’s my work-around anyways! :slight_smile:

Thanks

This thread explains the issue in depth: http://forum.unity3d.com/threads/168930-How-do-I-keep-a-button-active-on-click-event-with-toggle?p=1155139&viewfull=1#post1155139