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

Question Horizontal Layout Group Padding only allows INT values?

Discussion in 'UGUI & TextMesh Pro' started by Cooo_oooper, Mar 29, 2024.

  1. Cooo_oooper


    Apr 20, 2023
    Hello all,
    for my NPC barks I am currently trying to add text above their heads in world space with a background image like so:
    The Image has a Horizontal Layout Group, Content Size Fitter and a Script called "Image With Rounded Corners" on it that just rounds the corners. The Text, a TextMeshProUGui also has a content size fitter on it so it scales according to the text.
    All in all the scaling is working fine and the Image gets sized according to the length of the text. However I wanted to set some padding left and right of the text so it does not intersect the rounded corners.
    However the Horizontal Layout Group only allows INT values in the padding, making the padding 1unit in WorldSpace which does not fit well:

    A workaround I found is just adding a few spaces in front of the text I want but this does not work for the Right side of the text.
    Any help on how I can get some nice padding would be greatly appreciated!
    soundsosound likes this.