I've started Unity and scripting a week ago so please, feel free to treat me like an idiot ^^ I threw a javascript together that's supposed to show a message when you click on a key, and then lets you choose whether to pick it up.
private var gotKey : boolean = false;
private var showMsg : boolean = false;
function OnMouseDown()
{
showMsg = true;
function OnGUI ()
{
if (showMsg = true)
{
GUI.skin.box.wordWrap = true;
GUI.Box(Rect(100,50,500,200),"It's the key to the door that leads to the mysterious and unknown outside wooooooorld.
(Press E to pick it up, press R to cancel)");
}
}
function Update()
{
if (Input.GetButtonDown ("e"))
{
gotKey = true;
Destroy (gameObject.Find("key"));
}
if(Input.GetButtonDown ("r"))
{
showMsg = false;
}
}
}
It looks fine to me. But I get this error message: Assets/Scripts/getKey.js(8,18): BCE0044: expecting (, found 'OnGUI'. So it expects me to just write function()? Please help...