Search Unity

TextMesh Pro Background behind Text Lines?

Discussion in 'UGUI & TextMesh Pro' started by jGate99, Apr 19, 2021.

  1. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,944
    Hi there,

    How can i set a background behind text just like in this image?
    image.jpg


    Please advise
     
  2. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,944
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You should be able to either use the <mark> tag or to implement your own background by querying the textInfo of the individual text objects to determine the position and size of each background element to be placed behind the text.

    There should be a few posts about the instantiation and positioning of background elements on the forum. Here is a link to an older post that should prove useful. I am not sure if this old implementation still works but it should get you in the ballpark if the <mark> tag doesn't work for you.
     
    jGate99 likes this.
  4. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,944
    Thank you very much, mark is great tag

    Few questions:
    - Does highlight appear behind the text?
    - Can you please add possibility of marging for mark underlay so we can show either bigger or smaller (something like stikethrough) ?
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The geometry of the <mark> tag is contained in the main text object where as such, it can appear behind the text. This is an issue that I will be addressing in the future.

    In the meantime, there is a trick where you can assign a static font asset that only contains the underline character to the text object and then assign as local fallback another (either dynamic or static) font asset that contains all the other glyphs. This setup results in the underline being drawn first and the characters coming from the fallback over it.

    The mark tag does include a padding attribute which can be used as follows:
    <mark color="#FF800080" padding="5, 5, 5, 5">A</mark>
     
    jGate99 likes this.
  6. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,944
    It'd be really great if support for appearing as underlay appear in weeks rather than months.
    With this feature, and TMpro, ill be able to make some beautiful typography related experiences.
    Thanks
     
  7. oliver_unity892

    oliver_unity892

    Joined:
    Oct 28, 2019
    Posts:
    91
    Did a background mask (mask behind the text, or an underlay) get added to TextMeshPro at all? It would be a great feature, not only stylistically, but also to enhance reading on certain backgrounds.
     
  8. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,944
    Any update on this?
     
  9. LexaMV

    LexaMV

    Joined:
    Feb 20, 2018
    Posts:
    28
    Any update on this?
     
  10. taedal5

    taedal5

    Joined:
    Feb 2, 2021
    Posts:
    11
    Any update on this?
     
  11. Lenabozz

    Lenabozz

    Joined:
    Apr 14, 2019
    Posts:
    1
    Any update on this?
     
    brendantuite likes this.
  12. Nsingh13

    Nsingh13

    Joined:
    Dec 17, 2014
    Posts:
    38
    Any update on this?
     
  13. leechiahwa99

    leechiahwa99

    Joined:
    Jun 20, 2023
    Posts:
    1
    Any update on this?
     
  14. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,944
    Hi there,
    Any update on this feature? Really need it, or anyother workaround possible?
     
  15. charles_swierczek

    charles_swierczek

    Joined:
    Sep 5, 2023
    Posts:
    1
    Any update on this?
     
  16. BigRedz_VR

    BigRedz_VR

    Joined:
    Dec 20, 2023
    Posts:
    1
    Guessing there is still no update on this?
     
  17. Mel-ancholy

    Mel-ancholy

    Joined:
    Jul 4, 2023
    Posts:
    1
    Any update on this?
     
    jGate99 likes this.