- Home /
Unity can't load level
Hi! I've been working on this sidescroller game for quite a while. Everything is going quite good, but I have a problem. Unity can't load any levels when I'm using Application.LoadLevel.
For example, here's my JS code to load a level with a jet plane:
#pragma strict
function Update() {
if(Input.GetMouseButtonDown(0))
Application.LoadLevel (JetLevel);
}
But I get this error. And yes I do have my scenes in the build settings.
Any ideas on what I should do to get this fixed?
Thanks a lot! :)
Answer by robertbu · Oct 08, 2013 at 04:00 PM
JetLevel needs to be in double quotes:
Application.LoadLevel ("JetLevel");
Application.LoadLevel() as two versions, one uses names, the other uses numbers.
Thank you so much! That fixed it! :)
Just another question, will "Get$$anonymous$$ouseButtonDown" work on touch devices too or will I have to rewrite the code for those?
You will have to rewrite for touch. Consider purchasing one of third-party mouse/touch abstraction packages. We use FingerGestures, but there are other, and perhaps some free ones. With these, for much of your coding you can write once for both mouse and finger.
Your answer
Follow this Question
Related Questions
Getting a black screen within Build completed with 'Succeeded' 0 Answers
On carachterspawn level load error? 0 Answers
LOTS of build errros 0 Answers
Help please guys thank you so much! 1 Answer