Before updating to Windows 10 you may need to return your Pro license. More information here

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,


more ▼

asked Oct 18, 2011 at 09:46 PM

avatar image

61 25 19 23

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Oct 18, 2011 at 10:03 PM

avatar image

121k 80 365 774

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Oct 18, 2011 at 09:46 PM

Seen: 5028 times

Last Updated: Oct 18, 2011 at 10:05 PM