- Home /
UI Text Not being centered
My UI text (newest Unity, 5.01f1) has some problems with the UI text not being centered. The bottommost line in a textbox is, sorta centered, but about 20 pixels too far to the left. Once the line wraps THAT line gets centered properly, but the new bottommost line becomes off-center. Any idea what's going on? Picture attached.
Thanks!
Answer by nyonge · May 10, 2015 at 09:16 PM
Note - for anyone left wondering, it was the font itself, like the actual ttf file. No idea what the problem was but switching that font out for a different but similar one solved the issue. (And on the plus side, the new font looks way better.)
Thanks for that note, I was having a similar problem and changing the font back to default Arial centered the text block. I don't know how long it would have taken without your advice!
Answer by pfreese · Apr 22, 2015 at 12:16 AM
That has been noted as a bug and a fix is in the works. For a work-around, try adding an extra blank line to your text.
Answer by Pharaoh_ · Apr 21, 2015 at 07:23 PM
Tick Best Fit. Make a tiny change, such as hit spacebar and then delete it to allow the change to occur (it sometimes bugs for me).
Then you either need to allow more space or make the font size fit the text field's width and height manually, by script.
The spacing is fine, the text actually renders outside of the text box when it's offset in the bottom row. The problem seems to be the UI component not being able to properly calculate the Center aligned position.
Your answer
Follow this Question
Related Questions
How do I place a left or right aligned Text where it would be if it was center aligned? 0 Answers
how to align 2 different text together with scoring 1 Answer
How to align text? 1 Answer
Planning Text Scroll with Unity UI 0 Answers
UI Text.LineSpacing doesn't work when the Text has only one line ? 1 Answer