From e778a23a062a22d9cb3cf24399e0a85f2c8f656a Mon Sep 17 00:00:00 2001 From: yurui <952870061@qq.com> Date: Thu, 29 Aug 2024 15:35:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=87=E6=8D=A2=E4=B8=BB?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E6=89=93=E5=BC=80=E4=B8=BB=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=97=B6=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Code/Scripts/Gameplay/Game/GameStateMainScene.cs | 3 ++- .../LoadingExecutor/CampSceneLoadingExecutor.cs | 2 +- .../LoadingExecutor/MainSceneLoadingExecutor.cs | 6 ++++-- .../Gameplay/PVP/PVPManager.DefenderPrepare.cs | 2 +- .../UI/UI_Interface/UI_MainPanelController.cs | 8 ++++++++ .../Code/Scripts/Gameplay/Utils/CommonUtils.cs | 12 ------------ 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Game/GameStateMainScene.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Game/GameStateMainScene.cs index 4952ab33705..ef10db0f051 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Game/GameStateMainScene.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Game/GameStateMainScene.cs @@ -43,8 +43,9 @@ public class GameStateMainScene : IState EventManager.Instance.Unregister(EventManager.EventName.LoadingExecutorComplete, OnLoadingComplete); } - private void OnLoadingComplete() + private async void OnLoadingComplete() { + await UI_MainPanelController.Open(); callbackAction?.Invoke(); } } \ No newline at end of file diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/LoadingExecutor/CampSceneLoadingExecutor.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/LoadingExecutor/CampSceneLoadingExecutor.cs index b61bf7b3fa6..d3cc31a066f 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/LoadingExecutor/CampSceneLoadingExecutor.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/LoadingExecutor/CampSceneLoadingExecutor.cs @@ -17,7 +17,7 @@ namespace Gameplay { progress = 0.5f; - await OpenUIWithScene(UINameConst.UI_Camp, Constants.CAMP_SCENE_PATH, null, true, LoadSceneMode.Single); + await OpenUIWithScene(UINameConst.UI_Camp, Constants.CAMP_SCENE_PATH, LoadSceneMode.Single); ShowManager.Instance.RefreshShow(E_ShowSceneType.Camp); diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/LoadingExecutor/MainSceneLoadingExecutor.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/LoadingExecutor/MainSceneLoadingExecutor.cs index bc713dc8c4a..733bf4877f3 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/LoadingExecutor/MainSceneLoadingExecutor.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/LoadingExecutor/MainSceneLoadingExecutor.cs @@ -4,6 +4,7 @@ using cfg.ShowCfg; using Cysharp.Threading.Tasks; using Framework; using Gameplay.SubSystems; +using PhxhSDK.Res; using UnityEngine.SceneManagement; using static Gameplay.CommonUtils; using static UI_MainPanelController; @@ -69,11 +70,12 @@ namespace Gameplay } //================== - UISceneResult uiSceneResult = await OpenUIWithScene(UINameConst.UI_MainPanel, scenePath, null, false, LoadSceneMode.Additive); + SceneHandle sceneHandle= await GameSceneHelper.Instance.LoadSceneForUIView(scenePath); // 主场景 + //UISceneResult uiSceneResult = await OpenUIWithScene(UINameConst.UI_MainPanel, scenePath, LoadSceneMode.Additive); progress = 0.8f; - if (GetSceneRootComponent(uiSceneResult.sceneHandle.Scene) == null) + if (GetSceneRootComponent(sceneHandle.Scene) == null) { DebugUtil.LogError($"无法进入主场景,{typeof(ShowComponent).Name}不存在,scene path:{scenePath}"); return E_LoadingResult.ErrorTest; diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/PVP/PVPManager.DefenderPrepare.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/PVP/PVPManager.DefenderPrepare.cs index 1a32656a393..afadc69c4bb 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/PVP/PVPManager.DefenderPrepare.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/PVP/PVPManager.DefenderPrepare.cs @@ -21,7 +21,7 @@ public partial class PVPManager public async void EnterDefendPrepare() { await TerrainTypeConfig.Load(); - await CommonUtils.OpenUIWithScene(UINameConst.UI_PVPDefendPrepare, _pvpLevelInfo.LevelScene, null, true, + await CommonUtils.OpenUIWithScene(UINameConst.UI_PVPDefendPrepare, _pvpLevelInfo.LevelScene, LoadSceneMode.Additive, (sceneHandle) => { var tgs = UnityEngine.Object.FindObjectOfType(); diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/UI_Interface/UI_MainPanelController.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/UI_Interface/UI_MainPanelController.cs index 6d554b1bdf8..55a28db7682 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/UI_Interface/UI_MainPanelController.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/UI_Interface/UI_MainPanelController.cs @@ -30,6 +30,14 @@ using Gameplay.Performance.Cmp; /// public class UI_MainPanelController : UIWindow { + /// + /// 打开主界面 + /// + public static async UniTask Open() + { + return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_MainPanel); + } + /// /// 用于表示等级滚动所扫过的范围 /// diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Utils/CommonUtils.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Utils/CommonUtils.cs index 79e94d041f3..2956bcb6d45 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Utils/CommonUtils.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Utils/CommonUtils.cs @@ -1544,23 +1544,11 @@ namespace Gameplay /// public static async UniTask OpenUIWithScene(string uiName, string scenePath, - object uiParam = null, - bool openLoadingUI = true, LoadSceneMode loadSceneMode = LoadSceneMode.Additive, Action loadSceneFinish = null) { //隐藏上层UI UIManager.Instance.HideAllUI(UINameConst.UI_LoadingInterface, UINameConst.UI_LoadingProgressInterface); - //先加载场景 - if (openLoadingUI) - {/* - //如果要打开加载UI - LoadingExecutorWithUILoadingController loadingExecutor = new() - { - GetProgress = () => GameSceneManager.Instance.GetSceneLoadingProgress(scenePath) - }; - await LoadingManager.Instance.ExecuteLoading(loadingExecutor);*/ - } SceneHandle sceneHandle = await GameSceneHelper.Instance.LoadSceneForUIView(scenePath, loadSceneMode); if (sceneHandle == null)