- Home /
Application.LoadLevel always loads level 0
I am having a problem with my scene changing script. My game is almost finished except for a problem which i cannot seem to solve. My game has a Main Menu scene which holds a terrain and a canvas with buttons. The "Start Game" button references a script on the button itself, and calls a function upon click: function ChangeScene () { Application.LoadLevel("GOODSECOND"); }
Whenever I click it is supposed to load the second level. But it always results in reloading the main menu level. I tried using LoadLevel(1) as well. This appears to be happening only with the level 1 & 2. Setting LoadLevel to 3 or 4 works fine. This made me believe it was the other scenes fault. I tried copying everything to new scenes in case they were corrupted but no luck in that. This also happens when you try to load level 2 from level 1, it load level 0.
Has anyone experienced this before? Can someone please help me with it? It is holding back the game from being finished.
Yes, they are there. I should have mentioned that in the description.
I just placed the Debug.Log on awake and indeed, level 1 is loaded then level 0 is loaded immediately. It appears i might have to do a check on every script in the level.
Thank you! I just checked all the scripts in the second level and found the culprit, which was a function that calls another function which says load level 0, at function Start() Thanks
Answer by meat5000 · Jul 04, 2015 at 02:30 AM
Are the other scenes somehow firing another LoadLevel, taking you back to 0?
Put a Debug.Log in the Awake() function somewhere in levels 1 and 2 so you can see if its being loaded and destroyed by another scene.
Answer by starikcetin · Jul 04, 2015 at 02:24 AM
Your codes may be going in a loop, may be a function triggers something that you don't expect to be triggered. That's all i can say with this type of question that has no code piece or screenshots.
Answer by W.Walter · Jul 04, 2015 at 02:24 AM
Check your build settings again, and the actual scenes they represent. There is no reason for this 'bug' other than a stupid mistake.
Your answer
![](https://koobas.hobune.stream/wayback/20220611225709im_/https://answers.unity.com/themes/thub/images/avi.jpg)