Page 1 of 1

text not staying inside buttons

Posted: Tue Nov 15, 2022 10:42 pm
by cristoo
Hi does anyone know why my text isn't staying inside the buttons? I have wrap, truncate and best fit checked.
I have tried so many combinations of settings and haven't found a solution yet.
Any help would be much appreciated.
You can see what I mean in the bottom two player response buttons on this experiment.

Re: text not staying inside buttons

Posted: Wed Nov 16, 2022 9:03 am
by Tony Li
Hi,

You may need to add some padding on the top and bottom of the button. Here's an example:

padResponseText.png
padResponseText.png (125.07 KiB) Viewed 129 times

This button happens to use a Vertical Layout Group. Notice that the Top and Bottom padding move the text in from the top and bottom edges of the button image. Otherwise the text would overlap the top edge of the button image.

If you're not using a Vertical Layout Group, you can inspect the text GameObject itself and instead of the padding of its Rect Transform instead.

In addition, it will help to set the text's vertical alignment to middle instead of top.