- Home /
How do you change the margin, padding, and border size of GUILayout buttons?
I want to use more precise measurements for where things go in my menus, but I can't find out how to manually manipulate the automatic space between each button. Am I supposed to use a GUIStyle, and if so, how on Earth am I supposed to go about doing it? I looked over the documentation, but it's something of a maze when it comes to this topic...
So what I'm most interested in specifically is how to set the space after a new GUILayout.BeginHorizontal() and a new GUILayout.Button? Elaboration and a clear description with some examples would be great.
Thanks so much for your time!
Answer by Jake-L · Dec 27, 2011 at 02:47 PM
First you'll need to create your own GUIStyle:
// create a style based on the default label style
GUIStyle myStyle = new GUIStyle (GUI.skin.label);
// do whatever you want with this style, e.g.:
myStyle.margin=new RectOffset(11,22,33,44);
and then pass this to Popup() or any other method taking a GUIStyle parameter.