Scaling GUI text

Hello,

I am having problems with GUI text. When I scale it to look fine on my screen everything is ok, but when I change the screen, text looks too big. Is there some other whey to display text so that it looks the same on every screen?

thanks

Well, the way you’d do this is make your text scale some percentage of the screen.

I have tried that, but when I put variable in a place of text size, text won’t appear…

this is what I have and it won’t work:

var MySkin : GUISkin;
var textH : double = Screen.height/1920 * 200;
var textW : double = Screen.width/1080 * 200;

var score : int;
var Score : String = score.ToString();

function OnGUI () {

	GUI.Label (Rect (0, 0, textW, textH), Score, MySkin);

}

Your code only changes the size of the box that the text is in, it doesn’t change the size of the text. Try:

	void OnGUI() {
		GUIStyle g = GUI.skin.GetStyle("label");
		g.fontSize = (int)(20.0f + 10.0f * Mathf.Sin(Time.time));
		GUI.Label(new Rect(10, 10, 200, 80), "Hello World! 你好世界");
	}