Can't troubleshoot this GUI bug

So I’m having an error that I shouldn’t have at all as far as I know. the following code returns this error for each line of it.

function OnGUI () {
	GUI.Box (Rect (0,0,100,50), "Top-left");
	GUI.Box (Rect (Screen.width - 100,0,100,50), "Top-right");
	GUI.Box (Rect (0,Screen.height - 50,100,50), "Bottom-left");
	GUI.Box (Rect (Screen.width - 100,Screen.height - 50,100,50), "Bottom-right");
}

MissingMethodException: Method not found: ‘GUI.Box’.
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.ProduceExtensionDispatcher ()
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.Create ()
Boo.Lang.Runtime.RuntimeServices.DoCreateMethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object args)
Boo.Lang.Runtime.RuntimeServices.CreateMethodDispatcher (System.Object target, System.String name, System.Object args)
Boo.Lang.Runtime.RuntimeServices+c__AnonStorey12.<>m__6 ()
Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key,

Any idea what I broke?

Could you tell us the filename of the script in question? It looks like it’s trying to run it in Boo, but what you’ve written looks more like javascript!

Just on a hunch, what happens if you replace it with this-

import UnityEngine
import System.Collections

class example(MonoBehaviour):

    def OnGUI():
        GUI.Box (Rect (0,0,100,50), 'Top-left')
        GUI.Box (Rect (Screen.width - 100,0,100,50), 'Top-right')
        GUI.Box (Rect (0,Screen.height - 50,100,50), 'Bottom-left')
        GUI.Box (Rect (Screen.width - 100,Screen.height - 50,100,50), 'Bottom-right')

I’m not so good at Boo, but if that compiles then it means that you’re using the wrong file extension on your script file.

It’s a .js file. GUI.js to be specific. I checked again to make sure I wasn’t just blind to the problem. The code compiles, it just shoots me run time errors all day.

Your ‘GUI’ filename is overriding the UnityEngine.GUI type! Change the name of your file, or, if it’s completely necessary for you to call it that, explicitly call UnityEngine.GUI.Box in all those lines, and see if the problem goes away.

(answer by @syclamoth, not me)