Exemple #1
0
    IEnumerator LoadSceneAsync(int scene)
    {
        Debug.Log("Starting to load " + LevelPrefix + scene);
        //AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(LevelPrefix + scene);
        AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(scene);

        while (!asyncLoad.isDone)
        {
            yield return(null);
        }

        UpdateReferences();
        if (_uiController != null)
        {
            _uiController.ActivateLoadingScreen();
        }

        //_uiController.UpdateLevelTitle("Level " + scene);
        _uiController.UpdateLevelTitle(LevelNames[scene - 1]);

        if (_loadWithCheckpoint != -1)
        {
            _player.transform.Translate(new Vector3(_loadWithCheckpoint, 0, 0));
        }

        for (float i = LevelLoadingTime; i > 0; i -= .01f)
        {
            _uiController.UpdateGameReadyTime(i);
            yield return(new WaitForSecondsRealtime(.01f));
        }

        InitializeLevel();

        _lastCheckpoint     = -1;
        _loadWithCheckpoint = -1f;

        _isLoadingLevel = false;
        _currentLevel   = scene;
        GestureHandler.Instance.reset();
        Debug.Log("Done loading " + LevelPrefix + scene);
        yield return(null);
    }