- Home /
BCE0044: expecting :, found 'if' ???
Hi, I keep getting this message. I don't know what's wrong with it. I tried putting ';' on the last part of the if statement, the message still shows.
Thanks in advance.
Here's my code.
if (GUI.Button,(new Rect(10, 50, 50,20), Close))
clicked = false;
if it says expecting XXX but found "if" means something before your "if" is wrong. In addition you have a "," after Button which is wrong. It would help to see what's before the if...
Answer by Berenger · Jan 31, 2013 at 10:05 AM
I don't know what Close is, but I guess it's a string and you forgot the "". Remove the , after Button and your good.
if (GUI.Button(new Rect(10, 50, 50,20), "Close"))
clicked = false;
I've tried what you have said. the error is still there. :( i have also remove the close.
here's my code.
#pragma strict
var clicked = false;
function On$$anonymous$$ouseUp(){
clicked = true; }
function OnGUI() {
if (clicked);
{
GUI.Box(new Rect(20, 50, 100, 40), Box)
if (GUI.Button(new Rect(10, 50, 50, 20)));
clicked = false;
} }
GUI.Button needs at least two parameters, just the rect isn't enough (what is it supposed to display ??). Put back the close, just as it is in my answer.
As for the semicolon at the end of the if, it won't make an error, but the if will be ignored and clicked will be false right away => remove it.
The actual arror comes from the missing semicolon behind the GUI.Box line. So the semicolon after the if line should be on the GUI.Box line ;)
Thanks for all your help. Sorry, im still new to unity and javascript.
Your answer
Follow this Question
Related Questions
Expecting :, found ; and can't figure it out... 2 Answers
Various Code errors, found X was expecting Y, missing ";", and "can't declair functions on the fly" 2 Answers
How to get around adding loads of "if" commands in my script 2 Answers
Multiple function conditions? 1 Answer
3 errors in scrip. 1 Answer