Files
Continentis/Assets/Scripts/MainGame/Commands/Cmd_WaitForUI.cs
SoulliesOfficial ac98ec3aef 更新
2026-04-17 12:01:50 -04:00

33 lines
901 B
C#

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