- Home /
Fix editor TextField cursor alignment
Whenever I increase the font size of my TextField it makes the cursor and highlight shift down. Is there a way to fix this?
I'm using this custom GUIStyle:
MyStyle = new GUIStyle(EditorStyles.textField);
MyStyle.fixedHeight = 64;
MyStyle.alignment = TextAnchor.MiddleLeft;
MyStyle.fontSize = 32;
And I'm rendering the TextField like this:
query = EditorGUILayout.TextField(query, MyStyle,
GUILayout.Height(MyStyle.fixedHeight));
Removing the GUILayout.Height and fixedHeight don't seem to have an effect outside of layout (the cursor and highlight is still offset the same way).
Its not, just a regular TextField. Though I might try an InputField if I can't fix the regular TextField. Good suggestion.
Because InputTextField does't support having the text alignment on top or on bottom. Need to be center...
Ah, I just saw that InputField is New-GUI. This is for an editor extension so I can't use InputField.
Its for a popup window in the editor with a large query box:
Answer by jimfleming · Jan 26, 2015 at 09:13 PM
This turned out to be a font scaling issue. The solution is to create a font in the size needed since even dynamic fonts are not handled properly for text fields.
Your answer
Follow this Question
Related Questions
How to combine two buttons in one. Editor window 2 Answers
Custom Editor - Is there any way to detect whether the user is in Prefab editing mode? 1 Answer
Weird action in Unity editor when pressing the "E" key? 1 Answer
EditorGUILayout.TextField returning empty string 3 Answers
How can I determine when user presses enter in an editor text field? 3 Answers