| | |
| | | using UnityEngine;
|
| | | using UnityEngine.SceneManagement;
|
| | | using ProjSG.Resource;
|
| | | using YooAsset;
|
| | |
|
| | | public enum StageName
|
| | | {
|
| | |
| | | // public Action OnSwitchAccount;
|
| | | private LaunchWinData launchWinData = null;
|
| | |
|
| | | public async UniTask Init()
|
| | | public UniTask Init()
|
| | | {
|
| | | UIManager.Instance.OnCloseWindow += OnCloseWindow;
|
| | | return UniTask.CompletedTask;
|
| | | }
|
| | |
|
| | | public void Release()
|
| | |
| | | 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
|
| | |
| | | {
|
| | | 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;
|
| | |
| | |
|
| | | 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
|