yyl
2026-04-24 97de31e9a015cf139f5293a22e1575a43dfb6733
Main/Manager/StageManager.cs
@@ -4,6 +4,7 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using ProjSG.Resource;
using YooAsset;
public enum StageName
{
@@ -22,9 +23,10 @@
    // public Action OnSwitchAccount;
    private LaunchWinData launchWinData = null;
    public async UniTask Init()
    public UniTask Init()
    {
        UIManager.Instance.OnCloseWindow += OnCloseWindow;
        return UniTask.CompletedTask;
    }
    public void Release()
@@ -42,18 +44,29 @@
        LoadingWin loadingWin = await UIManager.Instance.OpenWindowAsync<LoadingWin>();
        InitLoadingWinData(loadingWin);
        // Phase 1 (0% ~ 60%): Scene loading
        AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("Login");
        asyncOperation.allowSceneActivation = false;
        while (!asyncOperation.isDone)
        // Phase 1 (0% ~ 50%): Scene loading
        if (AssetSource.isUseAssetBundle)
        {
            if (asyncOperation.progress >= 0.9f)
            var handle = YooAssetService.Instance.BeginLoadScene("Assets/ResourcesOut/Scenes/Login.unity", LoadSceneMode.Single, LocalPhysicsMode.None, true);
            while (!handle.IsDone)
            {
                asyncOperation.allowSceneActivation = true;
                if (handle.Progress >= 0.9f)
                    handle.UnSuspend();
                loadingWin.SetProgress(handle.Progress * 0.5f);
                await UniTask.Yield();
            }
            loadingWin.SetProgress(asyncOperation.progress * 0.5f);
            await UniTask.Yield();
        }
        else
        {
            var asyncOp = SceneManager.LoadSceneAsync("Login");
            asyncOp.allowSceneActivation = false;
            while (!asyncOp.isDone)
            {
                if (asyncOp.progress >= 0.9f)
                    asyncOp.allowSceneActivation = true;
                loadingWin.SetProgress(asyncOp.progress * 0.5f);
                await UniTask.Yield();
            }
        }
        // Phase 2 (50% ~ 100%): Manager initialization
@@ -89,7 +102,10 @@
    {
        UIManager.Instance.DestroyAllUI();
        await SceneManager.LoadSceneAsync("Login");
        if (AssetSource.isUseAssetBundle)
            await YooAssetService.Instance.LoadSceneAsync("Assets/ResourcesOut/Scenes/Login.unity");
        else
            await SceneManager.LoadSceneAsync("Login");
        Main.OnSwitchToLoginScene();
        currentStage = StageName.Login;
@@ -149,18 +165,29 @@
        SoundPlayer.Instance.StopBackGroundMusic();
        // Phase 1 (0% ~ 60%): Scene loading
        AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("Game");
        asyncOperation.allowSceneActivation = false;
        while (!asyncOperation.isDone)
        // Phase 1 (0% ~ 50%): Scene loading
        if (AssetSource.isUseAssetBundle)
        {
            if (asyncOperation.progress >= 0.9f)
            var handle = YooAssetService.Instance.BeginLoadScene("Assets/ResourcesOut/Scenes/Game.unity", LoadSceneMode.Single, LocalPhysicsMode.None, true);
            while (!handle.IsDone)
            {
                asyncOperation.allowSceneActivation = true;
                if (handle.Progress >= 0.9f)
                    handle.UnSuspend();
                loadingWin.SetProgress(handle.Progress * 0.5f);
                await UniTask.Yield();
            }
            loadingWin.SetProgress(asyncOperation.progress * 0.5f);
            await UniTask.Yield();
        }
        else
        {
            var asyncOp = SceneManager.LoadSceneAsync("Game");
            asyncOp.allowSceneActivation = false;
            while (!asyncOp.isDone)
            {
                if (asyncOp.progress >= 0.9f)
                    asyncOp.allowSceneActivation = true;
                loadingWin.SetProgress(asyncOp.progress * 0.5f);
                await UniTask.Yield();
            }
        }
        // Phase 2 (50% ~ 100%): Manager data ready