- Home /
Using GUILayout to arrange a text field next to a label
Hi! I'm creating a menu screen for a simulation I'm working on. I'd like to achieve the following layout of GUI elements:
|L1|TF1|
|B1|B2|
where:
L1 is a label saying "Port number: ".
TF1 is a textfield where the user can enter a number.
B1 and B2 are buttons.
I tried doing this using GUILayouts, but I'm not getting the expected results. This is the pseudocode of my approach:
// GUILayout.BeginArea
// GUILayout.BeginHorizontal
// GUILayout.Label -> Draws L1
// GUILayout.TextField -> Draws TF1
// GUILayout.EndHorizontal
// GUILayout.BeginHorizontal
// GUILayout.Button -> Draws B1
// GUILayout.Button -> Draws B2
// GUILayout.EndHorizontal
// GUILayout.EndArea
Although this code places L1 and TF1 in one row and B1 and B2 in the next, the text in L1 is not vertically aligned with the one in TF1. Is there any way to achieve that using GUILayouts? I've checked the documentation and wasn't able to find an answer for that.
Thanks in advance for your input!
Cheers,
--Nacho
Your answer
Follow this Question
Related Questions
Gui.Label chat system direction of label "stacking" 0 Answers
label text shadow 0 Answers
Fade out GUILayout Area? 1 Answer
Change the alingment of 2 GUILayout Label 0 Answers
GUILayout Icon + Text 3 Answers