Exemplo n.º 1
0
    IEnumerator SceneSwitchCoroutine(string sceneName, bool showLoadingScreen, ActionBetweenScenes actioneBetweenScenes)
    {
        _lastScene     = SceneManager.GetActiveScene().buildIndex;
        _lastSceneName = SceneManager.GetActiveScene().name;

        if (showLoadingScreen)
        {
            SceneManager.LoadScene("LoadingScene");
        }

        yield return(new WaitForSeconds(0.1f));

        if (actioneBetweenScenes != null)
        {
            actioneBetweenScenes();
        }

        SceneManager.LoadScene(sceneName);

        if (sceneName.EndsWith("Menu"))
        {
            if (!ABAudioController.Instance.IsPlayingMusic(_backgroundMusic))
            {
                ABAudioController.Instance.PlayMusic(_backgroundMusic);
            }
        }
        else
        {
            ABAudioController.Instance.StopMusic();
        }

        _currentScene     = SceneManager.GetActiveScene().buildIndex;
        _currentSceneName = SceneManager.GetActiveScene().name;
    }
Exemplo n.º 2
0
    IEnumerator SceneSwitchCoroutine(string sceneName, bool showLoadingScreen, ActionBetweenScenes actioneBetweenScenes)
    {
        _lastScene     = SceneManager.GetActiveScene().buildIndex;
        _lastSceneName = SceneManager.GetActiveScene().name;

        if (showLoadingScreen)
        {
            SceneManager.LoadScene("LoadingScene");
        }

        yield return(new WaitForSeconds(0.5f));

        if (actioneBetweenScenes != null)
        {
            actioneBetweenScenes();
        }

        SceneManager.LoadScene(sceneName);

        _currentScene     = SceneManager.GetActiveScene().buildIndex;
        _currentSceneName = SceneManager.GetActiveScene().name;
    }
Exemplo n.º 3
0
 public void LoadScene(string sceneName, bool showLoadingScreen = true, ActionBetweenScenes actioneBetweenScenes = null)
 {
     SMBSceneManager.Instance.StartCoroutine(SceneSwitchCoroutine(sceneName, showLoadingScreen, actioneBetweenScenes));
 }