Esempio n. 1
0
    IEnumerator _doLoadScene()
    {
        float timeCheck     = Time.time;
        float timeAnimation = _timeAnimation;

        _topPanel.gameObject.SetActive(true);
        while (true)           // animation show
        {
            float time = Time.time - timeCheck;
            _topPanel.setTranparent(Mathf.Clamp01(time / timeAnimation));
            if (time > timeAnimation)
            {
                break;
            }
            yield return(null);
        }
        SceneManager.LoadSceneAsync(_nextScene);
        while (!_nextSceneLoaded)           // wait unitl nextscene loaded
        {
            yield return(null);
        }
        timeCheck = Time.time;
        while (Time.time - timeCheck > _timeSimulation)
        {
            yield return(null);
        }
        timeCheck = Time.time;
        while (true)           // animation hide
        {
            float time = Time.time - timeCheck;
            _topPanel.setTranparent(1 - Mathf.Clamp01(time / timeAnimation));
            if (Time.time - timeCheck > timeAnimation)
            {
                break;
            }
            yield return(null);
        }
        _nextScene       = null;
        _nextSceneLoaded = false;
        _timeSimulation  = 0;
        _topPanel.gameObject.SetActive(false);
    }