- Home /
UI text android every screen size
so I have this score system which displays the score with a UI text and I want the text to be on the same spot and look the same for whatever screen size the game is displaying on, but I don't have a clue how to do this. I try'd to set the canvas scale to "scale with screen size" but this doesn't solve the problem.
The scale with screen size works, set it to match Height.
this works and the text stay's in the same spot and doesn't change size but everything else in my game does change size when the screen gets bigger (i use the fit all screen script from the asset store for all of my game objects but that doesn't work for text)
Answer by Mmmpies · Mar 02, 2015 at 10:58 AM
Put the text box where you want it on the canvas and size it how you want it sized. Then set the text to Best Fit and put the anchors to the corners of the Text's RectTransform.
That should scale the box with the canvas and Best Fit will scale the font size to fit in that box. Just make sure the smallest resolution has enough space for the text to be readable and you should be OK.
I don't get this to work do the fact that when I set it to best fit the text becomes massive even when it's on font size 1
Well BestFit scales the Font size to fit the RectTransform as close as possible to make it smaller make the box smaller.
Just make sure the height of the box is the size of the text you want and that the box is wide enough to fit however high your score can go up to. The only problem with BestFit is it'll shrink the text if you exceed the width of the box.
yes! I got it to work I first didn't understand what RectTransform meant but I got it now. Thank you