Jsbbvk
Jsbbvk

Reputation: 208

Unity3D GUI.Box, Scaling its text

In Unity3D I have this GUI Box that I scaled to the screen size. But the problem is that its text is not scaled correctly. The text has the same font size for any screen resolution. How can I set up the text's height and width when I display it? Screen Resolution is 1920 x 1080. Appreciate the help!

The Screen Resolution is 1920 x 1080 1

GUI.Box(new Rect(Screen.width / 2 - Screen.width / 6 / 2, Screen.height - Screen.height / 8, Screen.width / 6, Screen.height / 8), ("View [E]"));

Upvotes: 0

Views: 1227

Answers (1)

Jsbbvk
Jsbbvk

Reputation: 208

Turns out, you can make a new GUIStyle with the preferences you want.

GUIStyle myStyle = new GUIStyle(); 
myStyle.fontSize = 20;
GUI.Box(new Rect(Screen.width / 2 - Screen.width / 6 / 2, Screen.height - Screen.height / 8, Screen.width / 6, Screen.height / 8), "Hello", myStyle);

Link about more style are here: GUIStyles

Upvotes: 0

Related Questions