Ejemplo n.º 1
0
    IEnumerator LoadStage(Stage stage, Vector3 vecPlayerPos)
    {
        Time.timeScale = 0f;
        objUIBar.SetActive(false);
        GameObject objFadeCanvas = Instantiate(prefabSceneFade);

        DontDestroyOnLoad(objFadeCanvas);
        Image img = objFadeCanvas.GetComponentInChildren <Image>();

        yield return(FadeEffect(FADE.OUT, img));

        AsyncOperation ao = SceneManager.LoadSceneAsync(stage.sceneName);

        while (!ao.isDone)
        {
            yield return(null);
        }
        objPlayer.transform.position = vecPlayerPos;
        yield return(FadeEffect(FADE.IN, img));

        UIBar bar = objUIBar.GetComponent <UIBar>();

        bar.setTextStage(stage.stageName);
        objUIBar.SetActive(true);

        Destroy(objFadeCanvas);
        Time.timeScale = 1f;
    }