- Home /
What's wrong with my script?
I wrote my first enter code here C# script and i am giving errors, is it correct?
using UnityEngine;
using System.Collections;
public class HelpOptions : MonoBehaviour
{
public bool modesButton;
public bool controlsButton;
public bool goalButton;
public bool optionsButton;
public bool aboutButton;
public bool storyModeButton;
public bool survivalModeButton;
public bool challegeModeButton;
public bool questModeButton;
void OnMouseEnter()
{
renderer.material.color = Color.blue;
transform.localScale += Vector3(0.0009,0.0009,0);
}
void OnMouseExit()
{
renderer.material.color = Color.white;
transform.localScale += Vector3(-0.0009,-0.0009,0);
}
void OnMouseUp()
{
if(modesButton)
{
Application.LoadLevel(11);
else if(controlsButton)
{
Application.LoadLevel(12);
}
else if(goalButton)
{;
Application.LoadLevel(13);
}
else if(optionsButton)
{
Application.LoadLevel(14);
}
else if(aboutButton)
{
Application.LoadLevel(15);
}
else if(survivalModeButton)
{
Application.LoadLevel(8);
}
else if(challegeModeButton)
{;
Application.LoadLevel(9);
}
else if(questModeButton)
{
Application.LoadLevel(10);
}
else if(storyModeButton)
{
Application.LoadLevel(7);
User format code button to format your code. This is unreadable.
And we should now count the lines!? Not to mention your formatting might be different than it is in this post.
Copy the lines and paste them here...
it's the first "else if" and the last line of command "Application.LoadLevel(7);"
Answer by geniuscd · Jan 13, 2013 at 01:09 PM
do u have a collider on ur prefab/GameObject? check if the script is attached to the prefab/GameObject
OnMouseEnter(), OnMouseUp() needs collider in order to work when you click on them in the Game.
Answer by Wolfram · Jan 13, 2013 at 06:21 PM
Before that "else" there is a "}" missing. At the end of your script there are two "}" missing.
it fix the first one with the else but the last one is still there and yes i added the "}"
Did you add two? Don't you think it would help if you told us what the error actually says?
O$$anonymous$$, make that three "}", the class is missing its closing bracket, too.
(laughing) oh sorry, yes i did add two and the error says "Assets/Scripts/HelpOptions.cs(75,1): error CS8025: Parsing error"
Because compiler now actually had a change to compile somewhat correctly and found other shit you did wrong.
Your answer
![](https://koobas.hobune.stream/wayback/20220613090844im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
panel hide and show in NGUI 1 Answer
Unity isn't properly syncing with project 0 Answers
Equality and Inequality operators not found in DLL ??? 1 Answer