I’ve got this section of my code here:
void OnGUI(){
GUI.Label(new Rect(20, 10, 50, 60),": " + collected + "/60");
}
and i want to change the size of the GUI Label. I’ve tried changing the numbers but nothing seems to work. Please Help
I’ve got this section of my code here:
void OnGUI(){
GUI.Label(new Rect(20, 10, 50, 60),": " + collected + "/60");
}
and i want to change the size of the GUI Label. I’ve tried changing the numbers but nothing seems to work. Please Help
As far as I know, you can’t change the size in code. However, you can adjust the size in the Inspector. You have to create a new style. Use this script:
//Creates the new style. Name it whatever you want.
public GUIStyle customGUI;
void OnGUI() {
//Draws the label. For the last argument, be sure to use the same name you used to create the style.
GUI.Label(new Rect(10,10,500,300),"Hello, World!",customGUI);
}
Once you have this added to a GameObject, look in the Inspector to adjust the settings. As for adjusting the label, the first two arguments of “Rect” is the x and y position of the text, and the next two are how large of an area the text is shown in.
Links:
Make a GUIStyle, and change GUIStyle.fontSize.