From 9afd9057d71859af93c31e051425b956f26fab2a Mon Sep 17 00:00:00 2001 From: "DESKTOP-VVOCIJO\\PC" Date: Tue, 12 May 2026 17:58:51 +0900 Subject: [PATCH] =?UTF-8?q?2026-05-12=20SceneLoadManager=EC=9D=98=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../02_Scripts/Managers/SceneLoadManager.cs | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Assets/02_Scripts/Managers/SceneLoadManager.cs b/Assets/02_Scripts/Managers/SceneLoadManager.cs index 146c053f..16680a47 100644 --- a/Assets/02_Scripts/Managers/SceneLoadManager.cs +++ b/Assets/02_Scripts/Managers/SceneLoadManager.cs @@ -1,5 +1,4 @@ using System; -using System.Threading.Tasks; using UnityEngine; using UnityEngine.SceneManagement; public class SceneLoadManager : MonoBehaviour @@ -18,7 +17,6 @@ public class SceneLoadManager : MonoBehaviour // 정상(밝음) 상태에서의 스카이박스 _Exposure 값. 페이드 인의 도착 지점. [SerializeField, Min(0f)] private float _skyboxNormalExposure = 1f; - // 공유 에셋이 더러워지지 않도록 런타임 인스턴스로 복제해 사용 private Material _runtimeStartSkybox; private Material _runtimeLoadingSkybox; @@ -47,7 +45,6 @@ private void Awake() private void OnDestroy() { - // 런타임 복제 인스턴스는 직접 정리 if (_runtimeStartSkybox != null) Destroy(_runtimeStartSkybox); if (_runtimeLoadingSkybox != null) Destroy(_runtimeLoadingSkybox); } @@ -69,8 +66,6 @@ private void Update() //씬이 로드되었을때 호출 private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { - Debug.Log("씬 로드됨"); - if(scene.name == "GameScene") { MonoBehaviour[] allObjs = UnityEngine.Object.FindObjectsByType(FindObjectsSortMode.None); @@ -79,6 +74,7 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (obj is ISceneInitializable initializable) { + //씬에서 ISceneInitializable 인터페이스를 가진 오브젝트의 초기화 로직을 실행 initializable.OnSceneLoaded(); } } @@ -104,7 +100,6 @@ public async Awaitable FadeLoadingCanvas(bool isOut,float fadeTime) } // 현재 RenderSettings.skybox의 _Exposure를 from→to로 보간 - // Skybox/Procedural, /Cubemap, /Panoramic 셰이더 공통 프로퍼티 private async Awaitable FadeSkybox(float from, float to, float duration) { var sky = RenderSettings.skybox; @@ -165,17 +160,19 @@ private async Awaitable SceneChange(string sceneName) { try { + //로딩바 수치 0으로 설정 SetSceneLoadingProgressValue(0f); - //스카이 박스 페이드 아웃 로직 + //스카이 박스 페이드 아웃 await FadeSkybox(_skyboxNormalExposure, 0f, _skyboxFadeTime); // 검게 된 상태에서 머티리얼 교체 (교체 순간이 가려져 깜빡임 없음) RenderSettings.skybox = _runtimeLoadingSkybox; - //스카이 박스 페이드 인 로직 + //스카이 박스 페이드 인 await FadeSkybox(0f, _skyboxNormalExposure, _skyboxFadeTime); + //로딩창을 1초에 걸쳐 나타나게함 await SetSceneLoadingActive(true,1f); AsyncOperation op = SceneManager.LoadSceneAsync(sceneName); @@ -186,7 +183,7 @@ private async Awaitable SceneChange(string sceneName) //화면에 보여줄 로딩 수치 float displayProgress = 0f; - //op.progress 0.9가 데이터 로딩이 끝난 기준 allowSceneActivation이 트루면 바로 다음으로 넘어가면서 op.isDone이 true가 된다. + //op.progress 0.9가 데이터 로딩이 끝난 기준 allowSceneActivation이 트루면 다음으로 넘어가면서 op.isDone이 true가 된다. while (op.progress < 0.9f) { //실제 로딩 수치 @@ -195,26 +192,28 @@ private async Awaitable SceneChange(string sceneName) //보여줄 값을 실제값을 향해 부드럽게 이동 displayProgress = Mathf.MoveTowards(displayProgress, realProgress, Time.deltaTime * 0.5f); - // UI에 적용 + // 로딩바 UI에 값 적용 SetSceneLoadingProgressValue(displayProgress); - await Awaitable.NextFrameAsync(this.destroyCancellationToken); //자기자신이 파괴될때 토큰에 취소요청을 보냄 + //자기자신이 파괴될때 토큰에 취소요청을 보냄 + await Awaitable.NextFrameAsync(this.destroyCancellationToken); } + //로딩바 수치 1(100%)로 설정 (데이터 로딩은 이미 끝이기 때문에) SetSceneLoadingProgressValue(1); // 잠시 대기했다가 전환 await Awaitable.WaitForSecondsAsync(1.0f, this.destroyCancellationToken); + // 로딩바가 1초에 걸쳐 사라짐 await SetSceneLoadingActive(false,1f); - //스카이 박스 페이드 아웃 await FadeSkybox(_skyboxNormalExposure, 0f, _skyboxFadeTime); // 검게 된 상태에서 정상 스카이박스로 교체 RenderSettings.skybox = _runtimeStartSkybox; - //로딩 끝 + // 다음씬으로 넘어가도 됨을 알림 op.allowSceneActivation = true; // 씬 활성화가 완전히 끝날 때까지 대기 @@ -227,12 +226,8 @@ private async Awaitable SceneChange(string sceneName) //VR용 로직 //트래킹이 중단되면 안되기 때문에 카메라를 유지해야 한다 _loadingCamTargetTransform = Camera.main.transform; // 새로운 씬의 메인카메라를 따라가게끔 설정 - //------------------------------------------------------------------------------- - //스카이 박스 페이드 인 await FadeSkybox(0f, _skyboxNormalExposure, _skyboxFadeTime); - - Debug.Log("씬 전환됨"); } catch (OperationCanceledException) {