Search Unity

Fonts cannot be scaled

Discussion in 'UGUI & TextMesh Pro' started by RayAndGames, Mar 11, 2021.

  1. RayAndGames

    RayAndGames

    Joined:
    Sep 5, 2019
    Posts:
    9
    I can't scale the fonts without breaking it.

    The Canvas is rendered in World Space, and I added TextMeshProUGUI into the canvas. The canvas is the child of an object that can be scaled down by the player. Check the GIF below:

    How do I fix this?

    _TextError.gif
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    In order for the text to render correctly, scaling information must be passed to the shader. I suspect that in your case, TMP is unaware of the changes and as such cannot update the SDF Scale.

    For testing purposes, make the scale change and then select the text inspector and click the same alignment it is already using. This will force TMP to update the text object which should fix the text. Let me know if that does make the text render correctly?

    If it does, I need to have a better understanding of how you are making the change above. Are you in playmode when you make these changes?
     
  3. RayAndGames

    RayAndGames

    Joined:
    Sep 5, 2019
    Posts:
    9
    Thank you for replying!

    So I tried what you've suggested, but it seems like nothing changed. Even worse, the text now won't reappear after the scaling (watch the GIF below). This error only applies in game scene tho.

    _TextError.gif

    I decided to abandon my approach in using texts in my game, I use icons instead. But just in case, I want to know the solution for this problem.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Are you making these changes in Play mode or just in the Editor?

    This should be an easy thing to address once I understand how you are making these scale changes.

    P.S. Changing the shader used on the material used by these text objects to one of the SSD variant which are contained in the latest TMP Essential Resources should resolve this issue. The SSD shaders have the suffix SSD at the end of their names.
     
  5. RayAndGames

    RayAndGames

    Joined:
    Sep 5, 2019
    Posts:
    9
    Sorry for not being too clear. I made the changes in Play Mode using code. The player can press a key to access the scale of the other object to make it smaller.

    I have tried to change the shader of my font with Distance Field SSD just like you have suggested, and it works marvelously. _TextSolved.gif


    Thank you for helping me! I'll be forever grateful for your kindness ;)
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Glad to hear switching to the SSD shaders worked for your needs and you are most welcome :)