- Home /
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!
Answer by syclamoth · Oct 25, 2011 at 03:22 AM
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.
The Boo references are just because Unityscript is written in Boo.
I thought it was something like that. Which honestly makes more sense the more I think about it.
Answer by tortgurt · Oct 25, 2011 at 03:54 AM
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.
Please, use comments for comments.
Well, that's your problem then! 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.
Oh my, that was the right answer. I just couldn't figure out what went wrong. Thankss for the help!
Answer by AltIvan · Jul 20, 2014 at 02:21 AM
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)
Your answer
![](https://koobas.hobune.stream/wayback/20220613021650im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
[Solved] GUI Error? 1 Answer
Error: Optimized GUI Block text buffer 4 Answers
Wearied Error 1 Answer
Can I use the new GUI system with instantiated prefabs? 1 Answer
Unity UI flickering 1 Answer