Files
EnglewoodLAB/Assets/Scripts/Manager/SceneController.cs
SOOBEEN HAN f1894889ee <refactor> Octopus Twin 템플릿 적용
- 기능 외 UI 구조만 적용
- 프로젝트에 걸맞는 UI는 재작업 필요
2026-02-23 18:20:09 +09:00

87 lines
2.6 KiB
C#

using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace EnglewoodLAB.Management
{
public enum SceneStatus
{
None,
Chunil,
KepCo,
HyundaiWia
}
public class SceneController
{
private string currScene;
private string PrevScene;
private SceneStatus curSceneStatus;
public async UniTask SceneChange(string scene, SceneStatus sceneStatus)
{
if (currScene == scene)
return;
await PrevSceneUnLoad();
var operation = SceneManager.LoadSceneAsync(scene, LoadSceneMode.Additive);
while (!operation.isDone)
{
// float progress = Mathf.Clamp01(t.progress / 0.9f);
//if (progressBar != null)
//{
// progressBar.value = progress;
//}
//if (percentageText != null)
//{
// percentageText.text = Mathf.RoundToInt(progress * 100f) + "%";
//}
//// Check if the loading is nearly complete (at 90%)
//if (operation.progress >= 0.9f)
//{
// // This is the final 10% where the scene is ready but not yet active
// // You can add a manual delay or wait for a user input here
// // For a smooth transition to 100% and activation:
// progressBar.value = 1f;
// if (percentageText != null)
// {
// percentageText.text = "100%";
// }
// // Allow the scene to activate, completing the loading process
// t.allowSceneActivation = true;
//}
//prevSceneAssets.Add(scene);
await UniTask.NextFrame();
}
Debug.Log($"{scene} : 씬로드 완료");
currScene = scene;
PrevScene = scene;
curSceneStatus = sceneStatus;
}
private async UniTask PrevSceneUnLoad()
{
if (PrevScene != null)
{
await SceneManager.UnloadSceneAsync(PrevScene);
PrevScene = null;
}
}
/// <summary>
/// Home일 경우 메인 systemScene 제외한 나머지 씬 언로드
/// </summary>
public async void OnClickHome()
{
await PrevSceneUnLoad();
curSceneStatus = SceneStatus.None;
currScene = null;
}
}
}