修改切换主场景打开主界面时机

main
yurui 2024-08-29 15:35:40 +08:00
parent 94c298a426
commit e778a23a06
6 changed files with 16 additions and 17 deletions

View File

@ -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();
}
}

View File

@ -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);

View File

@ -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<ShowComponent>(uiSceneResult.sceneHandle.Scene) == null)
if (GetSceneRootComponent<ShowComponent>(sceneHandle.Scene) == null)
{
DebugUtil.LogError($"无法进入主场景,{typeof(ShowComponent).Name}不存在,scene path:{scenePath}");
return E_LoadingResult.ErrorTest;

View File

@ -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<TerrainGridSystem>();

View File

@ -30,6 +30,14 @@ using Gameplay.Performance.Cmp;
/// </summary>
public class UI_MainPanelController : UIWindow
{
/// <summary>
/// 打开主界面
/// </summary>
public static async UniTask<UIWindow> Open()
{
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_MainPanel);
}
/// <summary>
/// 用于表示等级滚动所扫过的范围
/// </summary>

View File

@ -1544,23 +1544,11 @@ namespace Gameplay
/// <returns></returns>
public static async UniTask<UISceneResult> OpenUIWithScene(string uiName,
string scenePath,
object uiParam = null,
bool openLoadingUI = true,
LoadSceneMode loadSceneMode = LoadSceneMode.Additive,
Action<SceneHandle> 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)