Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

GUIStyle fontSize offsetting the text insertion cursor position (y)

Discussion in 'Immediate Mode GUI (IMGUI)' started by trentdk, Jun 12, 2014.

  1. trentdk

    trentdk

    Joined:
    Jul 28, 2011
    Posts:
    22
    Hi,

    I'm having an issue when using any form of a TextArea or TextField where when changing the fontSize property of the GUIStyle for the TextArea the text insertion cursor's (blinking line) y position is offset.

    I'm currently using Unity version 4.5.0f6 and I do not have this issue on the previous version 4.3.4.
    Does this happen to anyone else?

    To reproduce,

    Code (CSharp):
    1.  
    2. string text= "";
    3. void OnGUI() {
    4.      GUIStyle style = new GUIStyle(GUI.skin.textArea);
    5.      style.fontSize = 36;
    6.  
    7.      text = GUILayout.TextArea(text, style, GUILayout.Width(400), GUILayout.Height(100));
    8. }
    9.  
     
  2. PeterPP2

    PeterPP2

    Joined:
    Jun 23, 2014
    Posts:
    2
    Yes, you are not alone. :( The same here in Unity 4.5.1f3.
     
  3. unimechanic

    unimechanic

    Joined:
    Jan 9, 2013
    Posts:
    155
  4. JFo

    JFo

    Joined:
    Dec 9, 2007
    Posts:
    217
    Case 622538
     
  5. JFo

    JFo

    Joined:
    Dec 9, 2007
    Posts:
    217
    As a workaround, you can generate a new font that has the matching size for the style's fontSize and use that for TextArea and TextField...
     
  6. zibas

    zibas

    Joined:
    Sep 15, 2010
    Posts:
    31
  7. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    740
    The bug was resolved and the fix is available in patch-release Unity 4.5.5p1 which can be downloaded here.
     
  8. oldbushie

    oldbushie

    Joined:
    Mar 30, 2012
    Posts:
    24
    I was seeing this issue in 4.5.5 and it is still present in Unity 4.6. Did that patch not make it to the 4.6 release somehow? All I'm doing is changing the font size of the text field. None of the other text field properties affect the cursor placement.
     
    Last edited: Dec 2, 2014
  9. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    740
    Hi, yes it was patched in 4.5.5p1 but the patches are not included in Unity 4.6.0f3 but will be added in Unity 4.6.0p1.
     
  10. oldbushie

    oldbushie

    Joined:
    Mar 30, 2012
    Posts:
    24
    Great! Thanks for the clarification, I'll keep an eye out.
     
  11. paynob

    paynob

    Joined:
    Oct 16, 2013
    Posts:
    2
    I'm still having this issue with 4.6.0p1
     
  12. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    740
    I could just reproduce the problem with 4.6.1, so it seems to be a regression :eek:. We will patch it asap.
     
  13. oldbushie

    oldbushie

    Joined:
    Mar 30, 2012
    Posts:
    24
    Thanks for keeping an eye on this! In actuality it seems like the text cursor is just the wrong size now, not off-center.
     
  14. oldbushie

    oldbushie

    Joined:
    Mar 30, 2012
    Posts:
    24
    Actually part of the wrong size was a bug in my code, I misspelled the font I was loading. So it is the correct size but offset a bit like you said still.
     
  15. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,245
    Thanks I look forward to it. This bug has been killing me. Would rather not have to do a dodgy workaround!
     
  16. unoKoudai

    unoKoudai

    Joined:
    Feb 5, 2015
    Posts:
    1
    unity 4.6.7p4 same issue.