Files

33 lines
901 B
C#
Raw Permalink Normal View History

2026-03-20 11:56:50 -04:00
using Cysharp.Threading.Tasks;
2026-04-17 12:01:50 -04:00
using SLSUtilities.General;
2025-10-03 00:02:43 -04:00
using UnityEngine;
namespace Continentis.MainGame.Commands
{
public class Cmd_WaitForUI : CommandBase
{
private readonly WaitableUIElement waitableUI;
2026-03-20 11:56:50 -04:00
private readonly bool autoHide;
2025-10-03 00:02:43 -04:00
public Cmd_WaitForUI(WaitableUIElement waitableUI, bool autoHide = true)
{
this.waitableUI = waitableUI;
this.autoHide = autoHide;
}
2026-03-20 11:56:50 -04:00
protected override async UniTask ExecuteAsync(CommandContext outerContext)
2025-10-03 00:02:43 -04:00
{
if (waitableUI == null)
{
2026-03-20 11:56:50 -04:00
Debug.LogError("[Cmd_WaitForUI] UI 元素为空,命令立即完成以避免队列卡死。");
return;
2025-10-03 00:02:43 -04:00
}
waitableUI.Show();
2026-03-20 11:56:50 -04:00
await waitableUI.OnConfirmAsync();
if (autoHide)
waitableUI.Hide();
2025-10-03 00:02:43 -04:00
}
}
}