반응형
씬 동기 로드
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Example : MonoBehaviour
{
public void LoadScene(int number)
{
SceneManager.LoadScene(number);
}
public void LoadScene(string name)
{
SceneManager.LoadScene(name);
}
}
씬 비동기 로드
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Example : MonoBehaviour
{
public Image sprite;
public Text progressLabel;
public string sceneName = "";
public void LoadScene(string name)
{
sceneName = name;
StartCoroutine(Load());
}
IEnumerator Load()
{
AsyncOperation async = SceneManager.LoadSceneAsync(sceneName);
while (!async.isDone)
{
float progress = async.progress * 100.0f;
int pRounded = Mathf.RoundToInt(progress);
sprite.fillAmount = async.progress;
progressLabel.text = (pRounded.ToString() + "%");
yield return true;
}
}
}
반응형