Beispiel #1
0
    private IEnumerator LoadPlanet()
    {
        AsyncOperation asyncLoad = SceneManager.LoadSceneAsync("Planet", LoadSceneMode.Additive);

        Planet    planetInfo = null;
        Coroutine coroutine  = StartCoroutine(FindObjectOfType <ApiController>().GetPlanet(planetId, (Planet detailedPlanetInfo) =>
        {
            planetInfo = detailedPlanetInfo;
        }));

        while (!asyncLoad.isDone)
        {
            yield return(new WaitForEndOfFrame());
        }
        yield return(coroutine);

        SceneManager.SetActiveScene(SceneManager.GetSceneByName("Planet"));

        PlanetController planetController = FindObjectOfType <PlanetController>();

        planetController.InitializePlanet(planetInfo);
    }