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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

TextMesh Pro Option to set whether TMP sprites should scale with the current font

Discussion in 'UGUI & TextMesh Pro' started by Edzc, Jul 8, 2021.

  1. Edzc

    Edzc

    Joined:
    Aug 18, 2017
    Posts:
    11
    So as the title suggests, there are two use cases. Sometimes you want a sprite to fit the scale of the current font, but sometimes an image (like a heart icon) needs to be in the same size across different fonts.

    Is there an option for that? Thanks!
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Sprites should already inherit the scale of the previous character provided you did not define Face Info metrics for the sprite asset.

    If Face Info metrics were defined then the sprite would respect that.

    Are you observing a different behavior?

    This handling did change over time in TMP so make sure you also test on the latest release which is version 1.5.6 for Unity 2018.4, version 2.1.6 for Unity 2019.4 and version 3.0.6 for Unity 2020 or newer.
     
  3. Edzc

    Edzc

    Joined:
    Aug 18, 2017
    Posts:
    11
    Thank you Stephan! Can I edit Face Info in the Editor? Or is it only accessible via code?
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    You can edit it right in the Sprite Asset Inspector as seen below.

    upload_2021-7-14_22-18-45.png
     
  5. Edzc

    Edzc

    Joined:
    Aug 18, 2017
    Posts:
    11
    Thanks! I set the Face Info, but the sprites are still scaling with the current font (somehow less obviously).
    I'm using Unity 2019.4.14f1 and TMP 2.1.6.
    TMP图标缩放问题.gif
     
  6. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    They should not be changing size. Can you post the settings that you used for the Face Info of the sprite asset?

    Also what font asset are you using for testing?

    Be mindful that the alignment of the sprites can be affected by the font asset metrics such as Ascent and Descent lines but their scale / size should not change.

    To verify those Face Info metrics between font assets and sprite assets, add the TMP_TextInfoDebugTool.cs to the text object. This script is located in the TMP Examples & Extras.
     
    Last edited: Jul 15, 2021
  7. Edzc

    Edzc

    Joined:
    Aug 18, 2017
    Posts:
    11
    The settings and fonts used are as follows (I'm only concerned with the Diamond):
    TMP图标缩放问题_1.png TMP图标缩放问题_2.png
    I will take a look at the debug script now.
     
  8. Edzc

    Edzc

    Joined:
    Aug 18, 2017
    Posts:
    11
    I added the debug script and turned on Show Character option. The dashed outline is indeed changing with the fonts. Is this normal?