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

TextMesh Pro How on earth do I nicely align a set of keys and values on a TMPro?

Discussion in 'UGUI & TextMesh Pro' started by EternalClickbait, Aug 29, 2020.

  1. EternalClickbait

    EternalClickbait

    Joined:
    May 5, 2019
    Posts:
    22
    For debugging purposes, I need to create a way to visualize a set of string keyvaluepairs (or tuples), such as version info, operating system etc. Something like:
    However, to make it look better and be easier to read, I would like it to be aligned, similar to a table: (sorry for the code block, only way to keep spacing)
    Platform:              WindowsEditor
    Version: 1.0.0.1
    Dummy 1: ABCD
    Very Long Name: AAAAAAAA

    I've tried doing this by using padding in string interpolation

    Platform: {Application.platform,padding}
    Version: {Application.version,padding}

    But even though it looks perfect in Rider, in the unity editor and TMPro it looks absolutely horrible, with no alignment whatsoever
    upload_2020-8-30_6-54-56.png upload_2020-8-30_6-55-59.png
    The unity console also looks really bad too:
    upload_2020-8-30_6-57-18.png
    I can use a monospace font, which looks fine in-game, but the unity console/inspector still don't match, and it's really trippy
    upload_2020-8-30_7-36-22.png
     

    Attached Files:

  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    With regards to TMP, you can use tabs \t as well as <pos=x.x> tags to better format the text.

    Tab width and tab multiple are defined per font asset in the font asset inspectors. Tab also uses tab stops.

    In the Console or Editor text fields which still use the Legacy text system, tabs are basically the only option available.
     
  3. EternalClickbait

    EternalClickbait

    Joined:
    May 5, 2019
    Posts:
    22
    @Stephan_B I tried using tabs, but I cant do it using
    string.Format()
    (it uses spaces not tabs). I guess I'll just use a monospaced font with TMP, but I really wish there was a way to modify the Console/Editor text field font.
    Also when is unity planning to switch from the legacy text systems? I've seen threads from 2013 talking about issues and it seems like non of them have been fixed yet. 7 years should be long enough for at least an alpha or even a beta