- Home /
Is it possible to detect which GUIStyleState is used?
Say I'm drawing a GUI.Button. Is it possible to tell if that Button will use the normal, hover, or any other GUIStyleState from the GUIStyle I give it?
I understand how the GUIStyle sets up each state, what I need to do is detect what the state will be for the current frame.
Answer by Mortoc · Jun 03, 2012 at 01:48 PM
Answering for posterity:
No, there is nothing in the API that lets you detect which state Unity decided to go with.
Answer by Lipis · Mar 11, 2010 at 12:59 AM
You can't exactly choose how to show your button, it depends on which state the button is currently is.
More details here (from Unity Script Reference on GUIStyle):
- normal: Rendering settings for when the component is displayed normally.
- hover: Rendering settings for when the mouse is hovering over the control
- active: Rendering settings for when the control is pressed down.
- onNormal: Rendering settings for when the control is turned on.
- onHover: Rendering settings for when the control is turned on and the mouse is hovering it.
- onActive: Rendering settings for when the element is turned on and pressed down.
- focused: Rendering settings for when the element has keyboard focus.
- onFocused: Rendering settings for when the element has keyboard and is turned on.
I didn't mean to set the style, I just need to detect which GUIStyleState Unity decided to use.
-$$anonymous$$ortoc
Has anyone found a solution on this yet? I have posted a similar question with no response: http://answers.unity3d.com/questions/10076/how-do-i-check-what-the-current-guistylestate-of-an-object-is