Ejemplo n.º 1
0
        public void SceneLoadedCallBack(object sender, SceneLoadedEvent showSceneEvent)
        {
            if (m_loadedSceneEvent != null)
            {
                foreach (callback call in m_loadedSceneEvent)
                {
                    call?.Invoke();
                }

                m_loadedSceneEvent.Clear();
            }
        }
Ejemplo n.º 2
0
    IEnumerator LoadScene(string _scene, bool _showLoadingScreen, string _unloadScene)
    {
        Application.backgroundLoadingPriority = ThreadPriority.Low;

        if (_showLoadingScreen == true && loadingMenuClasifier != null)
        {
            MenuManager.Instance.showMenu(loadingMenuClasifier);
        }

        yield return(new WaitForSeconds(delayTimer));

        AsyncOperation _sync = null;

        if (_unloadScene != "")
        {
            _sync = SceneManager.UnloadSceneAsync(_unloadScene);
            while (_sync.isDone == false)
            {
                yield return(null);
            }
            _sync = Resources.UnloadUnusedAssets();
            while (_sync.isDone == false)
            {
                yield return(null);
            }
        }

        if (currentLoadedScene != "" && SceneManager.GetSceneByName(currentLoadedScene).isLoaded)
        {
            _sync = SceneManager.UnloadSceneAsync(currentLoadedScene);
            while (_sync.isDone == false)
            {
                yield return(null);
            }
            _sync = Resources.UnloadUnusedAssets();
            while (_sync.isDone == false)
            {
                yield return(null);
            }
        }

        yield return(new WaitForSeconds(delayTimer));

        _sync = SceneManager.LoadSceneAsync(_scene, LoadSceneMode.Additive);
        while (_sync.isDone == false)
        {
            yield return(null);
        }

        yield return(new WaitForSeconds(delayTimer));

        Scene loadedScene = SceneManager.GetSceneByName(_scene);

        if (loadedScene != null && loadedScene.buildIndex != -1)
        {
            UnityEngine.SceneManagement.SceneManager.SetActiveScene(loadedScene);
        }
        //else
        //{
        //    throw new System.Exception("Scene not found in Scene Manager: " + _scene);
        //}

        currentLoadedScene = _scene;

        SceneLoadedEvent _event = new SceneLoadedEvent();

        EventManager.Instance.Raise(_event);

        if (_showLoadingScreen == true && loadingMenuClasifier != null)
        {
            MenuManager.Instance.hideMenu(loadingMenuClasifier);
        }

        Application.backgroundLoadingPriority = ThreadPriority.Normal;
    }
Ejemplo n.º 3
0
 public virtual void SceneLoaded(object sender, SceneLoadedEvent showSceneEvent)
 {
 }
Ejemplo n.º 4
0
 public void OnSceneLoadedCallBack(SceneLoadedEvent _e)
 {
 }