- Home /
Can you make a button enter its hover state with code?
Is it possible to manually change a GUI control's state?
I have two buttons that occupy separate rectangles.
I want them to share their state.
Answer by jahroy · Nov 29, 2011 at 06:28 PM
I think I found my answer already.
Looks like the GUIStyle.Draw() function is gonna be the ticket.
According to the documentation you can pass in booleans to determine the state.
can you give an example of how you did this? as usual the unity scripting guide isnt too detailed....
@gheeler - I haven't had access to a computer with a Unity setup in over a year. However, looking at the scripting guide, it looks like it tells you everything you need to know. There are five versions of the function GUIStyle.Draw(). Each one allows you to place different kinds of content in a rectangle: text, images, GUIContent, nothing, etc... Each function also takes as arguments a list of booleans that allow you to specifiy which "State" the control is in: hover, active, keyboard focus, etc... Note that this function is part of the GUIStyle class, so you might want to read more about that.
Your answer
![](https://koobas.hobune.stream/wayback/20220613060409im_/https://answers.unity.com/themes/thub/images/avi.jpg)