반응형
씬 동기 로드
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;
}
}
}
반응형
'개발 > C#' 카테고리의 다른 글
유니티 C# 로컬 데이터 저장, 불러오기 PlayerPrefs 간단 사용법 (0) | 2022.06.21 |
---|---|
유니티 C# 타이머 만들기 시분초 00:00:00 Timer (0) | 2022.06.21 |
유니티 C# 충돌 처리 OnTrigger Enter, Stay, Exit 간단 사용법 (0) | 2022.06.21 |
유니티 C# 코루틴 동작, 시간 딜레이 Coroutine, Invoke 간단 사용법 (0) | 2022.06.21 |
유니티 C# 랜덤 난수 생성 Random.Range 간단 사용법 (0) | 2022.06.21 |
유니티 C# 특수문자 제한 간단 사용법 input text (0) | 2022.06.21 |
유니티 C# 캐릭터 키보드 이동 간단 구현 (0) | 2022.06.20 |
유니티 C# 키보드 입력 Keyboard input 간단 사용법 (0) | 2022.06.20 |
댓글