Method not found: UnityEngine.GUI.Window

I’m really hoping for some help here - any suggestions appreciated.

Here’s my code. This exists in a single script attached to an object that exists at design time:

@HideInInspector
var tutorialState:int = 0;

@HideInInspector
var tutorialTitles:Array = new Array();
tutorialTitles.push("Title From Array");

@HideInInspector
var tutWindow:Rect = Rect(300,20,500,60);

function OnGUI ()
{
	var titleText = tutorialTitles[tutorialState];
	print(titleText);
	
	// only show tutorial window if tutorial state is meaningful
	if (tutorialState > -1)
	{
             // tutWindow = GUI.Window (0, tutWindow, DrawTutorialText, titleText);        
             tutWindow = GUI.Window (0, tutWindow, DrawTutorialText, "Some Title");
	}
}

function DrawTutorialText()
{
	GUI.Label(Rect(5,5,190,35),"Some Text Or Other");
}

When I run the project with the first “tutWindow = GUI.Window …” commented, it works fine and displays the window with Some Time as the title. It also prints “Title From Array” to the log.

When I switch the commented lines so that the second “tutWindow = GUI.Window…” is commented, the project compiles and runs, but I get “MissingMethodException: Method not found: UnityEngine.GUI.Window”, and the window of course doesn’t show. “Title From Array” is still written to the log.

This error is maddeningly non-sensical, and after three hours of trying everything I know to fix it I am seriously considering throwing the computer out the window. So, any help would be appreciated. Or, you can stand below my office window and catch a free computer in another hour or two. Just watch out for the glass shards.

Cheers,
Sean

edit: just in case it matters, Unity 3.30 (63135) on a Mac

you did not by error name your script file gui, right? otherwise you overwrote the “normal gui” class name, you would have to call GUI with UnityEngine.GUI.xxx

Hadn’t thought of that… but no, it’s called GameUniversals.js I do appreciate your answer though.

I’m beginning to think I will have to export all the assets and rebuild the project. I just tried the script in a “clean” project and it worked fine. Gah.

is there some other file named GUI in

Using Linux find with GUI, gui, Gui I don’t see anything, no.

The problem is that if you are using arrays this way the type of tutorialTitles[0] will be System.Object.

if you change your code to

var titleText:String = tutorialTitles[0];

Everything works correctly because unityscript is able to detect the correct parameters now.

The reason why print(titleText) works is because it takes a System.Object and converts it to a string for display.

That works… as usual it was my own ignorance what done me in. Thank you!

It does still leave me wondering why the error message was “Method not found”, that totally threw me off… maybe because the passed-in type didn’t match the expected.

Anyway, problem solved, huge thanks to you.