- Home /
The question is answered, right answer was accepted
Crash on LoadLevel (Android Project)
Hi.
My game crashes as soon as i hit a button which sends me on to next scene, does anyone know what the problem could be? I've updated to the late version of unity3d and nothing changed.
public void SetLevel(int i)
{
Application.LoadLevel(1);
SetLevel(i);
}
public void SetLevel(int index)
{
switch(index)
{
case 1:
...
break;
case 2:
...
break;
}
...
//Set the num of checkpoints to game control.
gc.checkpointsLeft = checkpointsLeft;
}
Answer by kromenak · Sep 16, 2013 at 06:40 AM
You are calling SetLevel recursively - look at line 4 of your code above. Two functions can have the same name, but they can't have the same number and types of arguments in the same order. That will surely confuse the compiler. If the code is actually written as you have it in your example, I'm kind of surprised it would even compile at all.
I'd change the name of one of those functions to something unique. That would remove the ambiguity that is probably causing your problem. Also, it seems you are loading level 1 no matter what value you pass to SetLevel.
oh my god lol, I don't believe I didn't see this. And why didn't the Visual Studio 2012 hadn't note me on the duplicated function? =/
Anyway, Thanks a lot mate!
EDIT:
The last function was on a different code, that's why it compiled, now I fixed it. the proper code should be "ClassName".SetLevel(i);
now it works.