GUI menu problems

Hi guys,

I can't figure out where I'm going wrong. The idea of this code is that it will be used with a collider on an NPC. When it's clicked with the mouse a GUI will pop up enabling the user to "ask questions".

I've tried this many different was and I can't seem to figure it out, which is really frustrting. I decided in the end it would be easier to write it like this:

private var isClicked : boolean = false;
var dialogueGUI : Texture2D;
var newSkin : GUISkin;

function dialogueMenu()
{

GUI.DrawTexture(Rect (0,0,700,450), dialogueGUI, ScaleMode.ScaleToFit, true, 1.0f);
}
function OnGUI()
{

GUI.skin = newSkin;

if(!isClicked) return;

dialogueMenu();

print ("dialogue GUI is displayed");
}

function OnMouseUp()
{
isClicked = true;
}

As you can see, OnGui - when the mouse is clicked - calls dialogueMenu() which will hold all the GUI data. But I'm getting this error:

ArgumentException: You are not allowed to call get_guiTexture when declaring a variable. Move it to the line after without a variable declaration. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. dialogueScript..ctor () (at Assets/Scripts/dialogueScript.js:2)

Anyone know why?

Your script works for me in Unity 3.2. (The click behavior is a little strange in my test scene, but I haven't investigated and that's not what you were asking about.)

FYI I googled your error and I didn't find other people having the same problem. Too bad, because that might have given us a clue.

Try assigning the default GUISkin, and a standard asset texture, just to make sure the problem isn't in those objects.

Is the script above the exact same as the script you are trying to compile? Try creating a new empty script and pasting the above text directly into it (which is what I did.) Just in case there's some weird corruption in the file, or hidden characters.

Are you sure this file is the one generating the error? If you cut most or all of the text out of it, does the error go away?