add Using UnityEngine.SceneManagement
public class SceneLoader : MonoBehaviour
{
public string sceneName;
public void LoadScene()
{
StartCoroutine(LoadAsynchronousOperation());
}
IEnumerator LoadAsynchronousOperation()
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName);
// Wait until the asynchronous scene fully loads
while (!asyncLoad.isDone)
{
yield return null;
}
}
}
Reference: