Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro Monospaced text using TMP_text.text

Discussion in 'UGUI & TextMesh Pro' started by gegagome, Feb 23, 2018.

  1. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    I am formatting time like this:
    _timerLabel.text = "<mspace=2.75em>" + Math.Floor(_stems[0].time).ToString();

    The text needs to be monospaced, I was wondering if that was the only way? I made a style but the above line assigns a new string.

    Also which do you recommend? TMP_text.text or TMP_text.SetText()?

    Thanks
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    SetText() is designed for concatenating a string with a variable without allocations so in this case SetText() is the better option.
     
  3. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    I wish the monospace feature was a check inside the TextMeshProUGUI component, but I guess the caps, small caps, etc options become tags/styles anyways.

    Thanks Stephan