GUI Button text color not changing on hover

I have a little main menu with a GUIButton. I’ve made a GUIStyle for the button so that the button text should turn cyan on hover. There are no errors, but hovering over the button does not make it cyan. Here is my code (it’s a C# script):

GUIStyle MenuItemStyle = new GUIStyle();
MenuItemStyle.normal.textColor = Color.white;
MenuItemStyle.hover.textColor  = Color.cyan;
	
int y = 200;
GUI.Button(new Rect(Screen.width / 2 - 50, y, 150, 30), "CAMPAIGN", MenuItemStyle);

Unless you want to completely define your style (backgrounds, colors for everything else, etc), you’ll want to derive your style from a style that is already defined. You’ll also want to make your GUIStyle variable public so you can assign its members. Something like this:

public GUIStyle MenuItemStyle;

void OnGUI()
{
    MenuItemStyle = new GUIStyle(GUI.skin.button);
    MenuItemStyle.normal.textColor = Color.white;
    MenuItemStyle.hover.textColor  = Color.cyan;
	
    int y = 200;
    GUI.Button(new Rect(Screen.width / 2 - 50, y, 150, 30), "CAMPAIGN", MenuItemStyle);
}

There is currently a small issue with the GUI.Button behavior (hover, active, focused, etc.) whenever you just uses text string : the behavior won’t work unless a image is placed as background.

While this is an issue, it’s not a bug. It’s a limitation due to fonts not being seen as picture. (Fonts don’t have the a predetermined Height and Width so Unity isn’t able to “link” its height and width to the registered Rect.)

The most simple way of fixing this is to add, in the GUIStyle, a single image made of 4x4 pixels and saved with a pure black alpha channel. By setting its type to GUI, it will actually be an empty invisible texture with almost no impact on performances.
By putting it as Background Image in the behavior dropdown menu (in the GUIStyle Inspector menu), Unity will then be able to give the Rect’s sizes adjustement to the area and it will work as intended.

Just make sure that if you do something like adjustable font size based on the player’s screen sizes that the Rect also adjust themselves, otherwise you’ll end up with areas that doesn’t fit the visual.