I have set the font size to 40 in “style.fontSize = 40;” However, no changes are being made. Help or guidance will be appreciated.
using UnityEngine;
using System.Collections;
//new using
using UnityEngine.SceneManagement;
public class MainMenu : MonoBehaviour {
public GUISkin skin;
public GUIStyle GUIStyle;
public Font f;
void OnGUI ()
{
GUI.skin.font = f;
GUI.skin = skin;
GUIStyle style = new GUIStyle();
style.fontSize = 40;
GUI.Label (new Rect (Screen.width/3, Screen.height/8, 1000, 1000), "Ice Crew");
if(PlayerPrefs.GetInt("Level Completed") > 0)
{
if(GUI.Button(new Rect (Screen.width/2.5f,Screen.height/1.5f,200,100), "Play"))
{
SceneManager.LoadScene(PlayerPrefs.GetInt("Level Completed"));
}
}
if(GUI.Button(new Rect (Screen.width/2.5f,Screen.height/2.5f,200,100), "New Game"))
{
PlayerPrefs.SetInt("Level Completed", 0);
SceneManager.LoadScene(1);
}
}
}
The specific issue you’re having in this case is that you create this GUIStyle but never use it anywhere.
But the more important, fundamental issue you’re having is that you’re using the old, deprecated UI system, and should learn the new system instead. It’s better-looking, easier to use, performs better, and more. The only reason to use the old UI system is legacy, that is, because you’ve been working on the same game since before 2013 (when the new system came out) and it’s too much trouble to change now… which I surmise is not the case here. If you’re looking for UI tutorials for Unity, you should make sure to use tutorials that specify they are for Unity 4.6 or higher.