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?