- Home /
button expansion is killing my layout
Hi, I have this piece of code
GUILayout.BeginVertical();
GUILayout.BeginHorizontal(); GUILayout.Label("Name"); constraintName = GUILayout.TextField(constraintName); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(); GUILayout.Label("Type"); if (GUILayout.Button(ctype)) { showNewConstraint = false; showTargetPicker = false; showConstraintPicker = true; } GUILayout.EndHorizontal(); GUILayout.EndVertical();
Basically I have this layout: label textfield label button now, the text of the button will change according to the user's input. when this input grows too big the button will expand on the left crushing the label. I've also tried using two vertical layouts arranged horizontally but when the button is too large the labels are pushed down. What i want is: 1) Left hand components must be aligned with their right hand components (current layout does this) 2) all components on the left must have the same width. same with the components on the left 3) the button should expand on the right, eventually causing the containing window to grow in width (I'm using GUILayout.Window wich should grow but it is not)
Now, using other gui toolkits i would solve this using a grid layout, but i don't know how to to this in unity
Answer by spinaljack · Aug 11, 2010 at 10:21 AM
http://unity3d.com/support/documentation/ScriptReference/GUILayout.MaxWidth.html
http://unity3d.com/support/documentation/ScriptReference/GUILayout.MinWidth.html
Use max width on the text area or min width on the button
can't use that. the text must be fully displayed, no matter how long it is