- Home /
BCE0044: (14,47) expecting :, found ','. makes no sense?
var Button1:Texture;
var Button2:Texture; var Button3:Texture; var Button4:Texture;
var myskin:GUISkin;
function OnGUI () { GUI.skin=myskin; }
if (GUI.Button (Rect ((Screen.width/2)-(Button1.width/2)-10,(Screen.height/2)-(Button1.height/2),300,200),Button1));
{
Application.LoadLevel ("Game"),
}
if (GUI.Button (Rect ((Screen.width/4)*3-(Button2.width/2)+140,(Screen.height/2)-(Button2.height/2),200,150),Button2)) {
Debug.Log("Button 2 Pressed");
}
if (GUI.Button (Rect ((Screen.width/4)*1-(Button3.width/2)-60,(Screen.height/2)-(Button3.height/2),200,150),Button3)) {
Debug.Log("Button 3 Pressed");
}
}
function Update () { }
$$anonymous$$akes perfect sense. Your code is all jacked up. What on earth is that comma doing after "Application.LoadLevel("Game")"? Don't you want this IF statement to BE in a function somewhere. It's just floating in space... And what about the semi-colon at the end of the line of the first IF statement? That makes no sense at all.
Answer by Bunny83 · Mar 25, 2011 at 12:02 PM
Never saw that many errors at once:
- All GUI stuff have to be inside the OnGUI. I guess the bracket after
GUI.skin=myskin;
is wrong. - The first button is terminated with a ";". That way the following code is not related to the if statement
- The error you get says "expecting ; found ,". After your
Application.LoadLevel
you have a ","(comma) but you need a ";"(semicolon) - If you don't need the Update function, remove it because it drains performance even when it's empty.
- Pick one indent style and keep it.
- If you post code here make sure you mark it as "code". There's a button at the top of the edit field (10101). See the Editing-help for more information.
Here's the corrected script:
var Button1:Texture;
var Button2:Texture; var Button3:Texture; var Button4:Texture;
var myskin:GUISkin;
function OnGUI () { GUI.skin=myskin;
if (GUI.Button (Rect ((Screen.width/2)-(Button1.width/2)-10,(Screen.height/2)-(Button1.height/2),300,200),Button1)) {
Application.LoadLevel ("Game");
}
if (GUI.Button (Rect ((Screen.width/4)*3-(Button2.width/2)+140,(Screen.height/2)-(Button2.height/2),200,150),Button2)) {
Debug.Log("Button 2 Pressed");
}
if (GUI.Button (Rect ((Screen.width/4)*1-(Button3.width/2)-60,(Screen.height/2)-(Button3.height/2),200,150),Button3)) {
Debug.Log("Button 3 Pressed");
}
}
Answer by AliAzin · Mar 25, 2011 at 08:42 AM
Try this:
var Button1:Texture; var Button2:Texture; var Button3:Texture; var Button4:Texture;
var myskin:GUISkin;
function OnGUI () { GUI.skin=myskin; }
if (GUI.Button (Rect ((Screen.width/2)-(Button1.width/2)-10,(Screen.height/2)-(Button1.height/2),300,200),Button1)){ Application.LoadLevel("Game");
if (GUI.Button (Rect ((Screen.width/4)*3-(Button2.width/2)+140,(Screen.height/2)-(Button2.height/2),200,150),Button2)) {
Debug.Log("Button 2 Pressed");
}
if (GUI.Button (Rect ((Screen.width/4)*1-(Button3.width/2)-60,(Screen.height/2)-(Button3.height/2),200,150),Button3)) {
Debug.Log("Button 3 Pressed");
}
}
function Update () { }
still have floating if(GUI....) statements not found in the OnGUI function. The first if(GUI.Button) has an open bracket and its closing bracket (I assume) is the one way at the bottom .. nesting 2 more GUI.Buttons .. which will never show up except for 1/30th of a second when the first IF is returned True.
This answer is incorrect.
Your answer
Follow this Question
Related Questions
Code Not Working. Any Ideas? 2 Answers
Script error. Please Help! 4 Answers
BCE0044: expecting ':' found ';' 1 Answer
Basic on collision play animation code not working 1 Answer
BCE0044: expecting :, found '=' 3 Answers