I have been working on a game recently and It's going very good. Today I started working on the menu and I created a button, but there is one problem, I have no idea how to change the size of the font :/
Here is the script:
I have been working on a game recently and It's going very good. Today I started working on the menu and I created a button, but there is one problem, I have no idea how to change the size of the font :/
Here is the script:
Pass a GUIStyle into the function and set the font size inside the GUIStyle.
Somthing like this should really work.
using UnityEngine;
using System.Collections;
public class FontSizeExample : MonoBehaviour
{
GUIStyle smallFont;
GUIStyle largeFont;
void Start ()
{
smallFont = new GUIStyle();
largeFont = new GUIStyle();
smallFont.fontSize = 10;
largeFont.fontSize = 32;
}
void OnGUI()
{
GUI.Label(new Rect(100, 100, 300, 50), "SMALL HELLO WORLD", smallFont);
GUI.Label(new Rect(100, 200, 300, 50), "LARGE HELLO WORLD", largeFont);
}
}
Ok so I researched the GUIStyle a bit and I did this:
var guiStyle : guiStyle;
and then I did
if(GUI.Button(Rect(playX, playY, sizePlayX, sizePlayY), "Play", guiStyle)) { code }
And I got a new thing in the inspector of the script where I could change everything, the font size, color only problem was that the border disappeard... Anyone know how to fix this ?