I am trying to make a box around some controls, kind of like a groupbox in .Net.
GUILayout.Box("Movement");
GUILayout.BeginVertical();
GUILayout.BeginHorizontal();
if (GUILayout.RepeatButton ( GUIContent( "", iconRotateLeft, "Turn Left"), GUILayout.Width(buttonWidth), GUILayout.Height(buttonWidth) )) {
GetComponent(FPSGUIMouseWalk).EnableAction("TurnLeft");
}
if (GUILayout.RepeatButton ( GUIContent( "", iconUp, "Forward"), GUILayout.Width(buttonWidth), GUILayout.Height(buttonWidth) )) {
GetComponent(FPSGUIMouseWalk).EnableAction("Forward");
}
if (GUILayout.RepeatButton ( GUIContent( "", iconRotateRight, "Turn Right"), GUILayout.Width(buttonWidth), GUILayout.Height(buttonWidth) )) {
GetComponent(FPSGUIMouseWalk).EnableAction("TurnRight");
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (GUILayout.RepeatButton ( GUIContent( "", iconLeft, "Move Left"), GUILayout.Width(buttonWidth), GUILayout.Height(buttonWidth) )) {
GetComponent(FPSGUIMouseWalk).EnableAction("Left");
}
if (GUILayout.RepeatButton ( GUIContent( "", iconDown, "Backward"), GUILayout.Width(buttonWidth), GUILayout.Height(buttonWidth) )) {
GetComponent(FPSGUIMouseWalk).EnableAction("Backward");
}
if (GUILayout.RepeatButton ( GUIContent( "", iconRight, "Move Right"), GUILayout.Width(buttonWidth), GUILayout.Height(buttonWidth) )) {
GetComponent(FPSGUIMouseWalk).EnableAction("Right");
}
GUILayout.EndHorizontal();
GUILayout.EndVertical();
The buttons arrange nicely in 2 rows of 3 buttons per row, but I can’t figure out how to get a box to automatically size itself to encompass the buttons.
The manual for GUILayout.Box states:
What does that mean?