Search Unity

How to draw a text underline?

Discussion in 'Immediate Mode GUI (IMGUI)' started by forest_linshs, Jan 19, 2010.

  1. forest_linshs

    forest_linshs

    Joined:
    Jan 6, 2010
    Posts:
    39
    Hi, everybody! I need your help.

    In GUIText , Label, or other captions, some keywords need to be signed by underline.

    like this

    I can't fix it. Could you give me any good suggestion?
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Unity imports a given font exactly as it is and can only use the original version (ie, it can't add styles on the fly). To get underlines, you should import an underlined version of the font separately and use it wherever necessary.
     
  3. forest_linshs

    forest_linshs

    Joined:
    Jan 6, 2010
    Posts:
    39
    Thanks for repay
     
  4. pallzoltan

    pallzoltan

    Joined:
    Apr 2, 2012
    Posts:
    11
    WOW, how stupid this is! I'm pulling my hair out trying to make a link look like a link. It's so dumb having to import every font a million times for every variation, and that Unity GUI is incapable of such basic tasks.
     
    Neuro2019, TorbenDK, vscza and 4 others like this.
  5. dkozar

    dkozar

    Joined:
    Nov 30, 2009
    Posts:
    1,410
    The answer above isn't completely true, because underline could be done with custom GUIStyle for your label using the background graphics. You could also set different graphics for normal, hover etc.

    Bold and italic couldn't be done this way though.

    Also, check out this link for CSS in Unity.
     
    CrandellWS likes this.
  6. OLP

    OLP

    Joined:
    Oct 19, 2012
    Posts:
    6
  7. Ghorre

    Ghorre

    Joined:
    May 7, 2014
    Posts:
    11
    Correct me if I'm wrong but ain't it possible nowadays with a RichText option ?
     
  8. eddieone

    eddieone

    Joined:
    Jul 19, 2014
    Posts:
    8
    Where to find underlined arial font?
     
  9. OLP

    OLP

    Joined:
    Oct 19, 2012
    Posts:
    6
    Rich text in Unity doesn't seem to support Underline yet, although I didn't try it: http://docs.unity3d.com/Manual/StyledText.html
     
    a436t4ataf likes this.
  10. Michieal

    Michieal

    Joined:
    Jul 7, 2013
    Posts:
    92
    Not trying to necro this, just this is the one that google pulls up when one searches for how to underline text in the UI (even on 5.6.1), so...
    The location of one's fonts in Windows is typically C:\Windows\Fonts. Unity will import and use most ttfs... (Adding for posterity, and new users.)
     
  11. Jace-Xanthos

    Jace-Xanthos

    Joined:
    Nov 25, 2017
    Posts:
    2
    My solution to the lack of underline was to duplicate the text object and replace the text to fill in the underline with adjacent underscores. The underscores look solid as long as you keep the transform of both text objects the same.
     
  12. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    4 years later ... this ought to be the answer, but still not fixed in Unity 2017. Might be fixed in 2018, but many people still using 2017 as the current most-stable release, so ...
     
  13. Muckel91

    Muckel91

    Joined:
    Nov 19, 2019
    Posts:
    1
    I don't get the problem.

    With TextmeshPro <u> and </u> works fine for me.
     
    won-gyu, kosta008, adepesters and 3 others like this.
  14. theolympicreefback

    theolympicreefback

    Joined:
    May 22, 2020
    Posts:
    6
    You can just create a textureless image, shape it as a line and put it under your text
     
  15. VishrutiFaldu

    VishrutiFaldu

    Joined:
    Feb 21, 2022
    Posts:
    4
    2022 and still a simple task as underline has such complex solutions
     
  16. rlaejrgh159

    rlaejrgh159

    Joined:
    Jan 12, 2022
    Posts:
    1
    I made underline like this,
    Make Image component, and Set its parent the text component.
    and add component "Content Size Filter" to text.
    then the size of RectTransform is changed according to length of text.
    also its child(Image component) also change.
     
  17. Christ81370

    Christ81370

    Joined:
    Sep 8, 2023
    Posts:
    1
    Hello, here is my tip:
    create a 1px black bottom border on the Label element.
     

    Attached Files: