how to change a scene in unity code example

Example 1: how do you switch scenes unity

using UnityEngine.SceneManagement;

SceneManager.LoadScene('Scene');

Example 2: change scene unity

SceneManager.LoadScene("name of scene", LoadSceneMode.Single);

Example 3: load scene unity

using UnityEngine.SceneManagement


public class LoadScene : MonoBehavior
{
	public string sceneToLoad = "Level2";
    
    public void Start()
    {
    	SceneManager.LoadScene(sceneToLoad);
    }
}

Example 4: change scene unity

SceneManager.LoadScene (sceneBuildIndex:/*Put the number here*/);