Unity Crashes on Run

When I added this script;

 void Awake()
    {
        SceneManager.LoadScene(0);
    }

every time I run the game, Unity fails to respond and crashes. Others have also had this issue.

Hi,

Did you see the solution in the other thread? In case you missed it, I’m copying and pasting in here.

I don’t know in which course and lecture you are but check if there is a game object which calls SceneManager.LoadScene(0); in the scene at buildIndex 0. See the scenes list in File > Build Settings.

I didn’t really understand what the solution was in that thread, but the index in build settings did match the code.

In that case, you have an endless loop. If there is an object in scene 0 with an Awake method which loads scene 0, scene 0 gets loaded, said Awake method gets called, scene 0 gets loaded again, and so on. I don’t know in which course and lecture you are but if you followed one of our video, there is very likely a difference between your project and the instructor’s.

Ohh, okay. So do you think there is a fix because I need the Awake() method in both scripts.

The problem is not the Awake method but the fact that scene 0 gets loaded in scene 0 without any restriction. To solve the problem, you will have to rethink your concept. In what case is scene 0 supposed to load scene 0? (Always = endless loop.)

This topic was automatically closed after 9 days. New replies are no longer allowed.

Privacy & Terms