Being in scene1 I want to load scene2, but also to disable scene1. How can I do that correctly?

Hello!

I have one scene in which player play the game and when he presses a UI button I’ve made I’d like to load scene2.

Firstly I tried that:

    public void LoadScene2()
    {
        SceneManager.LoadScene("scene2");
    }

but when it loads, I listen sounds from the first scene (I supposed the first scene was still in work).

So, I tried this in order to disable the first scene, but it didn’t help:

    public void LoadScene2()
    {
        SceneManager.LoadScene("scene2");
        SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene().buildIndex);
    }

Here is how I’ve successfully loaded scenes.

  IEnumerator LoadScene2 ()
    	{
    		AsyncOperation asyncLoad = SceneManager.LoadSceneAsync ("scene2");
    
    		while (!asyncLoad.isDone) {
    			Debug.Log ("Loading ...");
    			yield return null;
    		}
    	}

You’ll have to call StartCoroutine(LoadScene2); rather than LoadScene2(); let me know if it works.