- Home /
Do I have to make a GUIStyle with each control??
Hi, I am newbie and I got some problem with this blow. I want to change texture when hovering a button. With only one button, I can change it with its GUIStyle. What if I have more two buttons, do I have to create as many GUIStyle as buttons I create? Anyone, please, answer me. Thanks. :)
From reading the docs. I think you need GUIStyle per button as they only reference to one which you connected it with a script, but I could be wrong. There are some good GUI script examples out there, google some.
Ok i'll post my introduction as well ;)
http://answers.unity3d.com/questions/360901/editor-timeline-create-his-personnal-gui-timeline-.html
Answer by darkhog · Jan 23, 2013 at 04:53 PM
When you render buttons in one script, it's trivial. Just do something like this (C#):
public GUIStyle gangnamStyle;
void OnGUI(){
GUI.Button(new Rect(0,50,30,40),"Button1",gangnamStyle);
GUI.Button(new Rect(60,50,30,40),"Button2",gangnamStyle);
GUI.Button(new Rect(120,50,30,40),"Button3",gangnamStyle);
GUI.Button(new Rect(180,50,30,40),"Button4",gangnamStyle);
}
When button drawing routines are spread over multiple scripts, you should consider using GUISkin.
Your answer
![](https://koobas.hobune.stream/wayback/20220613091437im_/https://answers.unity.com/themes/thub/images/avi.jpg)