2026-05-29 로딩기능
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
public class SceneLoadManager : MonoBehaviour
|
||||
{
|
||||
public static SceneLoadManager Instance;
|
||||
|
||||
public GameObject LoadingScreen;
|
||||
public Image LoadingBack;
|
||||
public Image LoadingBar;
|
||||
public TMP_Text LoadingText;
|
||||
public TMP_Text LoadingDesc;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
@@ -47,11 +56,17 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
|
||||
public void SetSceneLoadingProgressValue(float value)
|
||||
{
|
||||
|
||||
LoadingBar.fillAmount = value;
|
||||
LoadingText.text = $"{(value * 100):F0}% 로딩중";
|
||||
}
|
||||
public void SetSceneLoadingProgressValue(float value,string loadingText)
|
||||
{
|
||||
|
||||
public void ShowLoadingScreen()
|
||||
{
|
||||
LoadingScreen.SetActive(true);
|
||||
}
|
||||
public void HideLoadingScreen()
|
||||
{
|
||||
LoadingScreen.SetActive(false);
|
||||
}
|
||||
|
||||
public void RequestSceneChange(string sceneName)
|
||||
@@ -66,6 +81,8 @@ private async Awaitable SceneChange(string sceneName)
|
||||
//로딩바 수치 0으로 설정
|
||||
SetSceneLoadingProgressValue(0f);
|
||||
|
||||
ShowLoadingScreen();
|
||||
|
||||
AsyncOperation op = SceneManager.LoadSceneAsync(sceneName);
|
||||
|
||||
//자동 전환을 하고 싶지 않을 경우 해당값을 false로 두었다가 true로 바꾸면 그 때 전환됨
|
||||
@@ -106,6 +123,7 @@ private async Awaitable SceneChange(string sceneName)
|
||||
await Awaitable.NextFrameAsync(this.destroyCancellationToken);
|
||||
}
|
||||
|
||||
HideLoadingScreen();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user