[Unity] Wait for the scene to load before proceeding to the next step

if (nextScene != "")
        {
            SceneManager.LoadSceneAsync(nextScene);
            yield return StartCoroutine(waitForLevelToLoad(nextScene));           
        }

private  IEnumerator waitForLevelToLoad(string level)
    {
        while (SceneManager.GetActiveScene().name != level)
        {
            Debug.Log("loading scene:" + SceneManager.GetActiveScene().name);
            yield return null;
        }
    }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325720937&siteId=291194637