Unity3D

Loading Scene Asynchronously for Unity

DragonTory 2020. 2. 26. 17:56
반응형

Loading Scene Asynchronously for Unity

비동기 씬 로딩 하기 및 로딩 프로그래스 바에 값 넘기기

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class LoadingScene : MonoBehaviour
{
    public string NextScene = "MainScene";
    public UISlider LoadingProgressBar;

    public void Start()
    {
        StartCoroutine( LoadNextScene() );
    }

    IEnumerator LoadNextScene()
    {
        AsyncOperation async = SceneManager.LoadSceneAsync( NextScene );

        while (async.isDone == false)
        {

            LoadingProgressBar.value = async.progress;

            yield return null;

        }

        LoadingProgressBar.value = 1.0f;

    } 

}

반응형