LoadSceneAsync Additive Issue

I am currently running into an issue with my scene loading. I have a main menu in its own scene. I then have a main game scene that has triggers to load and unload parts of my world as the player moves around indoors. The issue I am now running into is when I load the scene, everything works fine. But when I go back to my main menu and then try to immediately go back into the game the main game scene and the additive scene don’t do anything. They show up in my Hierarchy just fine and have the note (is loading…) but nothing is happening. The editor doesn’t freeze up or slow down, the FPS in playmode is still over 200 and task manager doesn’t show anything weird either. I am just at a lose for this now because I don’t understand what I am doing wrong.

The way I have my Main Menu button set up on my pause menu is basic.

    public void MainMenu()
    {
        SceneManager.LoadScene("Main Menu");
        SceneManager.UnloadSceneAsync("Full Model");
    }

From what I have learned while doing this project and from reading online this is the way to unload a scene while changing to another scene. But even if I remove the UnloadSceneAsync and just LoadScene I have the same issue.

I don’t know if this would affect anything but I am using the New Input System for activating and deactivating my pause menu and for player control.

First place to look is to see what scenes are loaded by looking in the Hierarchy window.

Next place might be to see if you set Time.timeScale to zero.

After that, time to debug your code! Here’s how to get started:

You must find a way to get the information you need in order to reason about what the problem is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

What is often happening in these cases is one of the following:

  • the code you think is executing is not actually executing at all
  • the code is executing far EARLIER or LATER than you think
  • the code is executing far LESS OFTEN than you think
  • the code is executing far MORE OFTEN than you think
  • the code is executing on another GameObject than you think it is
  • you’re getting an error or warning and you haven’t noticed it in the console window

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run? what order does it run in?
  • what are the values of the variables involved? Are they initialized? Are the values reasonable?
  • are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)

Knowing this information will help you reason about the behavior you are seeing.

You can also supply a second argument to Debug.Log() and when you click the message, it will highlight the object in scene, such as Debug.Log("Problem!",this);

If your problem would benefit from in-scene or in-game visualization, Debug.DrawRay() or Debug.DrawLine() can help you visualize things like rays (used in raycasting) or distances.

You can also call Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene manually, looking for all the parts, where they are, what scripts are on them, etc.

You can also call GameObject.CreatePrimitive() to emplace debug-marker-ish objects in the scene at runtime.

You could also just display various important quantities in UI Text elements to watch them change as you play the game.

If you are running a mobile device you can also view the console output. Google for how on your particular mobile target, such as this answer or iOS: https://discussions.unity.com/t/700551 or this answer for Android: https://discussions.unity.com/t/699654

If you are working in VR, it might be useful to make your on onscreen log output, or integrate one from the asset store, so you can see what is happening as you operate your software.

Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.

Here’s an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:

https://discussions.unity.com/t/839300/3

When in doubt, print it out!™

Note: the print() function is an alias for Debug.Log() provided by the MonoBehaviour class.

Right. I get all that. But the issue is nothing in the code has changed other then me finally adding in the pause menu script. I just want to know if there is a better way to change to the main menu scene and why when I first start the game everything works just fine as intended but when I return to the main menu and then return to the game nothing happens. I feel like the issue has something to do with how scene changes work and how to “reset” a scene upon leaving.

Also here is a screenshot of what I am talking about