- Home /
Font Size Change. Android.
so my game has a Gui Text and i notice when i play the game in the editor the font size is what i want it to be. but when i build and run it to my galaxy s5 i notice that the font is way to small. and ideas on how to fix it? i what the text to be consistent with all screen resolution. this is what i have so far on trying to fix the problem.`
public int FontSize; private float widthHeightRatio; public int num;
void Start ()
{
SetScale();
}
void SetScale()
{
widthHeightRatio = (float)Screen.width/Screen.height;
print (widthHeightRatio );
num = FontSize * Screen.width/Screen.height;
guiText.fontSize = num;
}
}`
Answer by Dazdingon · Jun 06, 2014 at 06:08 AM
Generally you would only need to multiply with the screen's height
Text that should be a 10th of the screen height would use :
guiText.fontSize = (int)(Screen.height * 0.1);
If you are developing for both a portrait and landscape layout,
you could try :
guiText.fontSize = (int)(Mathf.Min(Screen.height, Screen.width) * 0.1);
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
another android dpi question... 1 Answer
Help Understanding the Use of Unity with Android 1 Answer
Why Android crash after loading 3 models? 0 Answers
(Android) Timer change script help 0 Answers