I’m trying to change the font/color on a GUI using GUISkin (or GUIStyle, whichever will work). Here is my code it’s attached to a menu.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Menu : MonoBehaviour
{
public int MenuWidth;
public int MenuHeight;
public Texture Image;
public GUIStyle GUIStyle; // set the text style of the frame counter
Rect MenuRect;
// Start is called before the first frame update
void Start()
{
if ((MenuWidth == 0) || (MenuHeight == 0))
{
Debug.Log(“Menu size isn’t set”);
}
MenuRect = new Rect(Screen.width / 2 - MenuWidth / 2, Screen.height / 2 - MenuHeight / 2, MenuWidth, MenuHeight);
}
// Update is called once per frame
void Update()
{
}
private void OnGUI()
{
GUI.Box(MenuRect, “Main Menu”);
GUI.DrawTexture(new Rect(Screen.width / 2 - 30, MenuRect.yMin + 30, 50, 50), Image);
if (GUI.Button(new Rect(MenuRect.xMin + 20, MenuRect.yMin + 130, MenuRect.width - 100, 100), “PLAY”))
{
SceneManager.LoadScene(1);
}
if (GUI.Button(new Rect(MenuRect.xMin + 20, MenuRect.yMin + 225, MenuRect.width - 50, 100), “QUIT”))
{
Application.Quit();
}
}
I keep getting console errors, or the information shows up in the inspector but changing the inspector values doesn’t change anything in the GUI.