Hello, i’m making a main menu with 3d Text, and i make a code to the player click on the text and go to another level, but i make the code and give me this error, i can’t fix this, please help.
#pragma strict
function Start () {
}
}
else {
Application.LoadLevel("Niveis");
}
}
function Update () {
}
function OnMouseEnter () {
renderer.material.color = Color.red;
}
function OnMouseExit(){
renderer.material.color = Color.white;
}
Everything in your script except the Start function have proper code blocks, this is incorrect as you just have an else block with no if statement floating in the Start function.
function Start () {
} // this ends the Start function code bock
} // this confuses the compiler
else {
Application.LoadLevel("Niveis");
}
}
If you meant for the Start function to load a level, that would beg the question of your methods since this would immedately load a new level once Unity’s engine got things rolling in the scene.
So for right now, delete the Application.LoadLevel(“Niveis”) and the offending code block until you work out the logic that is appropriate for your implementation so things look like:
#pragma strict
function Start () {
}
function Update () {
}
function OnMouseEnter () {
renderer.material.color = Color.red;
}
function OnMouseExit(){
renderer.material.color = Color.white;
}
however if you really wanted to load a level within the Start function, remove the errenous blocks.
#pragma strict
function Start () {
Application.LoadLevel("Niveis");
}
function Update () {
}
function OnMouseEnter () {
renderer.material.color = Color.red;
}
function OnMouseExit(){
renderer.material.color = Color.white;
}
if you wanted a constraint on loading the level in Start, you need to work it out.
further more if you want to load a level with a button depending on the version you’re using either the OnGUI method or the newer UI structure of unity you need to state more then what this question has to offer.
#pragma strict
function Start () {
}
function Update () {
}
function OnGUI()
{
if (Rect (10,10,150,100), "Start Level")
{
Application.LoadlLevel("Niveis");
}
}
function OnMouseEnter () {
renderer.material.color = Color.red;
}
function OnMouseExit(){
renderer.material.color = Color.white;
}