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

<mark> or similar in background not as overlay?

Discussion in 'UGUI & TextMesh Pro' started by tylkomat, Jul 15, 2020.

  1. tylkomat

    tylkomat

    Joined:
    Jun 17, 2019
    Posts:
    22
    Is it possible to achieve this?
    TextHighlight.png
    The Sprite works, I know, but mark basically covers the text such that it won't be visible, unless there is alpha used.

    Is there another option?
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    This is due to the mark geometry being contained at the end of the primary mesh. As such, it is render on top of the characters.

    This is something that I need to revise to provide control over.

    In the mean time, you can cheat by forcing the text to use a sub text object thus leaving the mark geometry in the main mesh alone thus having it be rendered first / under the text.

    To do so, assign some font asset to the text object. This font asset can be a dynamic font asset or static one that only contains a few characters. Then in the text use the <font="Name of the font asset you want to use">The text.

    Using the <font> tag will force that text to be contained in a sub text object which will be rendered on top of the mark.
     
  3. tylkomat

    tylkomat

    Joined:
    Jun 17, 2019
    Posts:
    22
    Thanks that worked. I use the Default LiberationSansSDF asset. It does not work with the default material and overlay presets, but with all the others.