Esempio n. 1
0
    IEnumerator LoadScene()
    {
        yield return(null);


        AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(nextScene);

        asyncOperation.allowSceneActivation = false;


        float timer = 0.0f;

        while (!asyncOperation.isDone)
        {
            yield return(null);

            timer += Time.deltaTime;

            if (asyncOperation.progress >= 0.9f)
            {
                progressBar.fillAmount = Mathf.Lerp(progressBar.fillAmount, 1f, timer);

                if (progressBar.fillAmount == 1.0f)
                {
                    asyncOperation.allowSceneActivation = true;
                }
            }
            else
            {
                progressBar.fillAmount = Mathf.Lerp(progressBar.fillAmount, asyncOperation.progress, timer);
                if (progressBar.fillAmount >= asyncOperation.progress)
                {
                    timer = 0f;
                }
            }
        }


        if (isLoad)
        {
            saveNLoad = FindObjectOfType <SaveLoadController>();
            saveNLoad.LoadData();
        }
    }
Esempio n. 2
0
    IEnumerator LoadCoroutine()
    {
        AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(sceneName);

        float timer = 0.0f;

        while (!asyncOperation.isDone)
        {
            yield return(null);

            float progress = Mathf.Clamp01(asyncOperation.progress / .9f);

            timer += Time.deltaTime;

            progressBar.fillAmount = asyncOperation.progress;
            progressText.text      = progress * 100f + "%";

            if (asyncOperation.progress >= 0.9f)
            {
                progressBar.fillAmount = Mathf.Lerp(progressBar.fillAmount, 1f, timer);

                if (progressBar.fillAmount == 1.0f)
                {
                    break;
                }
            }
            else
            {
                progressBar.fillAmount = Mathf.Lerp(progressBar.fillAmount, asyncOperation.progress, timer);
                if (progressBar.fillAmount >= asyncOperation.progress)
                {
                    timer = 0f;
                }
            }
        }

        SaveLoad = FindObjectOfType <SaveLoadController>();
        SaveLoad.LoadData();
        gameObject.SetActive(false);
    }
Esempio n. 3
0
 public void ClickLoad()
 {
     Debug.Log("로드");
     SaveLoad.LoadData();
 }