Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

TextMesh Pro Unusable Transform

Discussion in 'UGUI & TextMesh Pro' started by OhiraKyou, Jul 14, 2017.

  1. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    248
    I've been trying to align a TMP text in world space (in editor), and it has been exceedingly frustrating. The values seem completely arbitrary, and trying to move a handle causes it to fly off screen and cause an invalid worldAABB error.

    Any other GameObject I throw onto a world space canvas with the following settings fills the canvas http://imgur.com/PFwxCtC

    But, not TMP; instead, it decides to sit outside the canvas with a ridiculous scale. I even tried copying the component values from a working RectTransform and pasting them into the TMP's RectTransform's values using the gear icon dropdown.

    And, while I was using a world space canvas for this example, I had the same problem with the TMP object by itself and simply thought that a canvas might help.

    But, now I'm out of ideas. Any suggestions?

    Versions
    Unity 2017.1.0f3
    TextMeshPro-1.0.55.2017.1.0b11
    Windows 10

    I had the same problem with Unity 5.5.1f1 and an associated TMP version.
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,625
    Since the normal TextMesh Pro component was designed to replace the 3D Text or TextMesh component, it has the same scale. Depending on camera setting - perspective or orthographic the scale also changes which again mirrors the implementation for TextMesh.

    In terms of the handles acting weird, it seems to work fine on my end so it might be helpful if you could provide a video showing the behavior that you are experiencing.
     
  3. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    248
    Then, it needs to be changed. The scale, as shown in my screenshot, is 1. Unity should respect that. It should not choose an arbitrary, hidden value as a scale when I have clearly set a scale of 1. It's currently inconsistent with other RectTransforms for no obvious reason and is completely unusable as a result. To the end user, such as myself, I see absolutely no reason why the text in my screenshot should be to the left of the canvas and much taller. It's entirely nonsensical.

    Video: https://gfycat.com/gifs/detail/HelpfulMiserableHake

    I feel I should stress that this happens regardless of whether or not the TMP object is a child of a world space canvas.
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,625
    There are two TextMesh Pro components. The first one located in "Create - 3D Object - TextMeshPro - Text" is a replacement for the 3D Text (TextMesh) also located in that menu. Both TextMeshPro and TextMesh components are designed to work with the Mesh Renderer. These are not designed to work with the Canvas system. They use the same scaling which is affected by the camera mode in terms of being Perspective vs. Orthographic.

    The other TextMesh Pro component is the TextMeshProUGUI component and is located in the "Create - UI - TextMeshPro - Text" menu and is designed to replace the UI.Text component. It is designed to replace the UI.Text component and works with the Canvas system and also uses the same scale.

    Since you are using a Canvas, you need to be using the correct TextMesh Pro component which is the TextMeshProUGUI location next to the UI.Text menu.

    Next, to adjust the size of the RectTransform, make sure you use the RectTransform tool



    When adjusting the Width and Height of the RectTransform, place the Rect Tool handle on the yellow line as shown in the image below or use the blue dots.



    When adjusting the margin of the text object (the yellow line), use the white dots as those adjust only the margin.

    Based on the video you provided, you are adjusting the margin instead of the RectTransform Width and Height and using the normal TextMeshPro component instead of the one designed to work with the Canvas system which has different scaling depending on the Canvas Render Mode like Screenspace Overlay, Screenspace Camera or Worldspace.
     
  5. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    248
    Like I said, the only reason I tried adding a canvas was because it was doing the same thing without one; the canvas was just a last resort test.

    But, I did solve this by creating a new TMP object, which is doing exactly what I'd expect. I forgot that the RectTransform tool was a thing and seemingly botched the margins. It may also have something to do with the automatic snapping tool I had active at the time.

    It feels really strange that the contents can be pulled out of their margins like that without a value updating in the inspector. If there's a separate box with values, we really need direct access to them. Unless I'm missing something, I strongly recommend exposing these values in the inspector window to make fixing these mistakes possible. There's no way I would have been able to fix those margins with the handles flying out of bounds like that. And, the perceived gap between what the exposed RectTransform values say about the object and what the object actually looks like complicates the debugging process in a major way.

    In any case, I have a working TMP object now. Pointing out the RectTransform tool led me in the right direction. Thanks.
     
  6. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,625
    The settings for the margins are in the Extra Settings panel which is collapsed by default.
     
  7. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    248
    Ah, got it. Thanks! I was too stuck on the idea that the settings were all font-related.
     
unityunity