Current location - Health Preservation Learning Network - Healthy weight loss - How to change the font size in Button when writing Unity3D script with JS?
How to change the font size in Button when writing Unity3D script with JS?
Hello, this is the code I used before, please refer to:

void OnGUI() {

//Create a style for the button

GUI style my button style = new GUI style(GUI . skin . button);

myButtonStyle.fontSize = 50

//Load and set the font

Font myFont = (Font) resources. Load("Fonts/comic ",type of(Font));

my button style . font = my font;

//Set the colors of the selected and unselected buttons.

mybuttonstyle . normal . text color = color . red;

mybuttonstyle . hover . text color = color . red;

...

//Use styles in buttons

bool testButtonTwo = GUI。 Button(new Rect( 10, 10,50,50)," test ",myButtonStyle);

...

}