Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Resolved Mark/highlight entire line to width of text object?

Discussion in 'UGUI & TextMesh Pro' started by Meridias561, May 16, 2024.

  1. Meridias561

    Meridias561

    Joined:
    Sep 9, 2022
    Posts:
    5
    I'm using a TextMeshProUGUI text object as an output for a text MUD game I'm making and I've been trying to work out a solution to a problem I've given myself and so far I can't figure it out. Is there a way to have a mark/highlight that spans the entire width of the text object but only on 1 text line, not the entire object? I'd rather not have to pad spaces on the end of the text.
     
  2. Meridias561

    Meridias561

    Joined:
    Sep 9, 2022
    Posts:
    5
    Well, turns out I had to get a little sneaky in order to get the effect I wanted without padding spaces or having to do object width/size of space character shenanigans and caret positions. So, just in case anybody else is wanting to have a mark highlight across an entire line, including whitespace past the end of the actual text, here's how I did it.

    "<mark=#ffff00aa>Blah blah text<pos=99.9%><size=0px>.</size></mark><br>"
    Yeah, that's a 0 pixel size period hidden at the end of the line to make the mark fill the entire line. Enjoy.