Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Question Can you use TextmeshPro with the regular transform component?

Discussion in 'UGUI & TextMesh Pro' started by petey, Oct 10, 2021.

  1. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,823
    Hi there,

    I was just wondering, is there a way to use the Text Mesh Pro component, with the standard Transform component rather than the Rect Transform? I thought you could just remove it but it doesn't seem to be the case.

    Thanks!
    Pete
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,686
    No, now that TextMeshPro implements the ILayoutElement interface, it has to have a Rect Transform. However, you can still access its transform property in code.
     
  3. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,823
    Thanks, well it’s good to know you can get to the transform.
    I just find rect transforms really annoying. :(
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    A RectTransform is used as we need some type of container to define the bounds (width and height).

    What specific part of using a RectTransform do you find annoying?
     
  5. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,823
    Hey Stephen, thanks, that makes sense.

    I guess a few of my annoyances are -
    I have to make sure any of my scripts that use Transform are also checking for RectTransform components and handling them independently.
    Width and Height have to be zeroed out for any object that doesn't use it, or it gets in the way of screen picking. This is all the time for me, unless I'm using TMPro because I use a lot of 3d in my UI. (Canvas also gets in the way of screen picking, Sort of off topic though).
    Also RectTransform is some kind of unusual class so it's hard to write editor scripts to help out. https://forum.unity.com/threads/rec...-of-unity-recttransform-custom-editor.455925/

    And, now that there's a new new UI system on the horizon, is canvas and RectTransform even sticking around?

    I'm just at the point where I want to simplify my workflow as much as possible so moving back to just transform would be nice.