Hello all. I am making a main menu for this new game I’m working on and I’ve encountered a weird outcome. I’ve been trying to create a menu that can scale depending on the res. I try to do this with the menuAreaNormalised var, but for some reason it doesn’t display anything. The area is completely empty where the buttons should appear.
using UnityEngine;
using System.Collections;
public class MainMenuGUI : MonoBehaviour {
public GUISkin menuSkin;
public Rect menuArea;
public Rect playButton;
public Rect instructionButton;
public Rect quitButton;
Rect menuAreaNormalised;
void Start()
{
menuAreaNormalised = new Rect (menuArea.x * Screen.width - (menuArea.width * 0.5f), menuArea.y * Screen.height - (menuArea.height * 0.5f), menuArea.width, menuArea.height);
}
void OnGUI()
{
GUI.skin = menuSkin;
GUI.BeginGroup (menuAreaNormalised);
if(GUI.Button(new Rect(playButton), "Play"))
{
}
if(GUI.Button(new Rect(instructionButton), "Instructions"))
{
}
if(GUI.Button(new Rect(quitButton), "Quit"))
{
}
GUI.EndGroup ();
}
}