- Home /
GUI does not contain a definition for Box
Hey guys, I'm a little baffled at why the following code does no compile:
using UnityEngine; using System.Collections;
public class MainTitle : MonoBehaviour {
// Use this for initialization void Start() {
}
// Update is called once per frame void Update() {
}
void OnGUI() { GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "This is a title"); } }
Am I missing something? As far as I'm aware, the GUI class most certainly contains a definition for Box. It's in every tutorial and every example I can find online!
I'm just trying to make a simple GUI for a class assignment. Anyone have any thoughts on why this isn't working? Maybe I need to import something?
Thanks for your help,
Fred
Answer by Eric5h5 · Oct 18, 2011 at 10:03 PM
You have a class of your own somewhere called GUI. It's better not to do that, because then you have to differentiate between your GUI and Unity's GUI. Also, please take 2 seconds and format your code when posting.
So obvious! Very helpful. Thank you Eric from 7 years ago!