how to change scenes in unity

Code Example - how to change scenes in unity

                
                        using System.Collections; 
using System.Collections.Generic; 
using UnityEngine; 
using UnityEngine.SceneManagement;

public class SceneScript {
  public void ChangeScene(string scene = "") {
    SceneManager.LoadScene(sceneName:"scenes Name");
  }
}
                    
                
 

unity load scene

                        
                                using UnityEngine.SceneManagement;

//Put this in whenever you want to load a scene
SceneManager.LoadScene("Scene name");
                            
                        
 

how to change scenes on collision unity

                        
                                void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
         SceneManager.LoadScene (2);
 }
                            
                        
 

Change Level in Unity

                        
                                public UnityEngine.UI.InputField sceneInputField; //Refence to your inputField

public void ChangeSceneBasedOnInputField() //Code that needs to be called
 {
      UnityEngine.SceneManagement.SceneManager.LoadScene(sceneInputField.text);  
     //This way you can type either the index of the scene or it's name
     //Will throw an error if it can`t find the scene
}