Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

TextMesh Pro Shrink or expand text to fit container width

Discussion in 'UGUI & TextMesh Pro' started by Lorcas_2714, Apr 21, 2024.

  1. Lorcas_2714

    Lorcas_2714

    Joined:
    Apr 12, 2024
    Posts:
    1
    Hi everyone, I'm starting to develop a TCG game and I have a question. I need to adjust the width of a font so that it can fill a specified width; in other words, if the text doesn't fill the container's width, increase the text width, and if it exceeds the width, decrease the text width, so the text fits entirely on the container. So far, the only close option is with Auto Size, increasing the %WD option by 50. However, this only works when the text exceeds the width, and it has a limit of increasing by 50%, which is insufficient for some texts. Other option that I found works is increase or decrease the X scale of the text object, but for that, I have to do a script, but I have not idea how to start it hahaha.
     

    Attached Files: