반응형
https://docs.unity3d.com/ScriptReference/AsyncOperation-progress.html
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using TMPro;
public class LoadingSceneManager : MonoBehaviour
{
private static string nextScene;
[SerializeField] private TextMeshProUGUI progressText;
public static void ChangeScene(string sceneName) {
SceneManager.LoadSceneAsync("LoadingScene");
nextScene = sceneName;
}
void Start()
{
StartCoroutine(loadScene(1f, nextScene));
}
IEnumerator loadScene(float delayTime, string sceneName)
{
AsyncOperation asyncOperation = SceneManager.LoadSceneAsync( sceneName );
asyncOperation.allowSceneActivation = false;
progressText.text = "Progress: " + asyncOperation.progress;
yield return new WaitForSeconds(delayTime);
asyncOperation.allowSceneActivation = true;
}
}
100%되고 1초 후 다음 씬으로 이동
반응형
'Unity > Unity 리서치' 카테고리의 다른 글
RectTransform의 width, height 알아내기 (0) | 2021.07.13 |
---|---|
영상(Video Player) 재생 (1) | 2021.07.12 |
Unity Language Localization (0) | 2021.07.11 |
TextmeshPro 한글폰트 적용 (0) | 2021.07.11 |
[Firestore] 커스텀객체(Custom Object) - Dictionary 변환 (0) | 2021.07.10 |