Editor GUI text becoming misaligned

Hi all,

I’m currently working on my editor extension and decided to add a custom button using an image instead, which was then put on the same row as a text field using a horizontal layout group

Unfortunately, the textfield stops being aligned to the centre.

2998689--223505--upload_2017-3-18_18-56-13.png

Here is the code in question with the problem

GUILayout.BeginHorizontal();
                 GUIStyle Style = EditorStyles.textField;
                 Style.alignment = TextAnchor.UpperLeft;
                 OutputPath = EditorGUILayout.TextField(new GUIContent("Output Path"), OutputPath, Style);
                 if (DesiredPathType == PathType.Absolute)
                 {
                     Style = GUIStyle.none;
                     Style.padding = new RectOffset(0, 0, 2, 0);
                     if (GUILayout.Button(new GUIContent(FolderIcon), Style, GUILayout.MaxHeight(16), GUILayout.MaxWidth(19)))
                     {
                         string Selection = EditorUtility.OpenFolderPanel("Output directory", RootPath, "");
                         if (!String.IsNullOrEmpty(Selection)) { OutputPath = Selection.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); }
                     }
                 }
                 GUILayout.EndHorizontal();

Does anybody know whats causing the issue and how I could fix it? Thanks

did you try giving the text the same height option GUILayout.MaxHeight(16)?

Yep, no luck

less optimal but put Output path in front of it as a label?

Hmm, I dont think this would be suitable since I want the user to have the ability to either type it into the textfield or use the file picker

ah no I mean the text.
as in:

GUILayout.BeginHorizontal();
                 GUIStyle Style = EditorStyles.textField;
                 Style.alignment = TextAnchor.UpperLeft;
                 GUILayout.Label("Output Path");
                 OutputPath = EditorGUILayout.TextField(OutputPath, Style);

and set some option parameters if it doesn’t layout as you want.

The issue is it isnt just the text thats misaligned, but the entire textfield too, so this could only slightly mitigate the issue at best