- Home /
GUIStyled button changes after being clicked
Hi,
I encountered following problem. I have a button and a style attached to it. Style has button's normal and hover background changed:
GUIStyle ButtonGUIStyle = new GUIStyle();
ButtonGUIStyle.normal.background = null;
ButtonGUIStyle.hover.background = (Texture2D)HoverFrame;
It works as expected. Unfortunately, when I press the button for a brief moment the style of it changes to default style. Does anyone have any suggestions why this happens?
This is pretty strange. As far as I understand it appears for only a few frames, but still is really noticable. Here is a screenshot to provide a better understanding of what happens (it is the same button).
I think there's another state in the lifecycle of a button, look again at the styles and see if there's something like 'active'
Answer by shopguy · Mar 14, 2014 at 10:26 PM
http://docs.unity3d.com/Documentation/Components/class-GUIStyle.html
Active Background image & Text Color when the mouse is actively clicking the Control
Focused Background image & Text Color when the Control has keyboard focus
Need to set one or both of those, both to be safe cross-platform/etc.
Yep. You were right. It really was "active" property. Thanks a lot!