using Cysharp.Threading.Tasks; using SLSFramework.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(); } } }