- Home /
Unity Keeps Giving Me Errors On My Scripts
Over the last few days unity has suddenly given me errors when i now save my scripts can you tell me why, when they were fine before? Here is an example:
Errors:
Assets/My Scripts/Component Click.js(35,1): BCE0043: Unexpected token: if.
Assets/My Scripts/Component Click.js(35,12): UCE0001: ';' expected. Insert a semicolon at the end.
Assets/My Scripts/Component Click.js(37,33): BCE0044: expecting :, found ';'
var isMotherboard = false;
var isCpu = false;
var isPsu = false;
var isGpu = false;
function OnMouseEnter()
{
renderer.material.color = Color.white;
}
function OnMouseExit()
{
renderer.material.color = Color.white;
}
function OnMouseUp()
{
if( isMotherboard )
{
Application.Loadlevel(2);
}
}
{
if( isCpu )
{
Application.Loadlevel(3);
}
}
{
if( isPsu )
{
Application.Loadlevel(4);
}
}
{
if( isGpu )
{
Application.LoadLevel(5);
}
}
Answer by ahaykal · Apr 27, 2013 at 01:43 PM
My advice for you is to comment your code and fix the alignment. Working Code:
var isMotherboard = false;
var isCpu = false;
var isPsu = false;
var isGpu = false;
function OnMouseEnter()
{
renderer.material.color = Color.white;
}
function OnMouseExit()
{
renderer.material.color = Color.white;
}
function OnMouseUp()
{
if( isMotherboard )
{
Application.Loadlevel(2);
}
if( isCpu )
{
Application.Loadlevel(3);
}
if( isPsu )
{
Application.Loadlevel(4);
}
if( isGpu )
{
Application.LoadLevel(5);
}
}
many thanks, also thanks for the tip i will do that in future
When your question is answered to your satisfaction, you click the check mark next to the answer. This removes the question from the 'unanswered' question list and makes it more likely to be viewed by someone with the same question.
I did it this time because too many questions get by with no answer marked correct.
Please see the FAQ and tutorial video linked on the right side of most Answers pages.
Your answer
Follow this Question
Related Questions
Script to load a text file gives error. 1 Answer
Save procedural mesh in the editor as asset. 2 Answers
Cant add bullet trail material to script - > Bullet Trail Prefeb 0 Answers
Send an activity from C# to Java 0 Answers
When I try to copy and paste something to my script... I get an error. 1 Answer