LoadLevel got Unity stuck

I’m trying to make a game with multiple levels. For each level, when player pass it , a canvas with choices will show up (basically player choose 1 ability out of 3, just like other roguelikes or hex tech in TFT). After picking 1 ability, the game will automatically enter next level.

So what i did was to addlistener on the ability choose button which cast a event.

The sceneManagement script will listen to that event and be responsible for loading the next scene. First it gets current scene, than get the index of current scene, add one to that and load the new scene.

This works for the first 3 levels. But everytime when it tries to load level 4, the Unity just stuck. And I have to reopen it. I dont know if it was the way I load the scenes that cause it, or any other reasons. I really appreciate if someone help me figure out, thanks a lot !

Try this options

  1. check if scene name is proper like in your case scene name should be level4 or level5.
  2. Make sure you have added that scene into the build settings.
  3. If all the above options are done already then, you need to check scene Level4 for having and endless loop which making unity stuck. Check any script where you might have started a loop but it’s condition is not getting false so it is stuck in infinite loop.

If this not worked, then try providing more information about Level4 scripts.

Yes I found out that there’s an endless loop that would happen when loading level 4. Thanks a lot for the solution ! Have a nice day !