using System; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; using UnityEngine.Localization.Components; using UnityEngine.UI; namespace DDD { public class ConfirmUi : PopupUi, IEventHandler { [SerializeField] private TextMeshProUGUI _messageLabel; [SerializeField] private LocalizeStringEvent _messageLabelLocalizeStringEvent; [SerializeField] private Button _cancelButton; [SerializeField] private Button _confirmButton; private Action _onCancel; private Action _onConfirm; // TODO : 마지막 팝업에서만 NAVIGATION protected override GameObject GetInitialSelected() { return _confirmButton.gameObject; } protected override void Start() { base.Start(); _messageLabel.text = string.Empty; EventBus.Register(this); Close(); } protected override void OnDestroy() { base.OnDestroy(); EventBus.Unregister(this); } public void Invoke(ShowConfirmPopupUiEvent evt) { _messageLabelLocalizeStringEvent.StringReference = LocalizationManager.Instance.GetLocalizedString(evt.NewMessageKey); _cancelButton.onClick.RemoveAllListeners(); _confirmButton.onClick.RemoveAllListeners(); _onCancel = () => { evt.OnCancel?.Invoke(); Close(); }; _onConfirm = () => { evt.OnConfirm?.Invoke(); Close(); }; _cancelButton.onClick.AddListener(() => _onCancel?.Invoke()); _confirmButton.onClick.AddListener(() => _onConfirm?.Invoke()); _cancelButton.gameObject.SetActive(evt.IsCancelButtonVisible); Open(); } // TODO : 두 팝업 사이의 문제 해결 protected override void OnInputPerformed(RestaurantUiActions actionEnum, InputAction.CallbackContext context) { base.OnInputPerformed(actionEnum, context); switch (actionEnum) { case RestaurantUiActions.Cancel: HandleCancelPerformed(); break; case RestaurantUiActions.Interact1: HandleInteract1Performed(); break; } } private void HandleCancelPerformed() { _onCancel?.Invoke(); } private void HandleInteract1Performed() { EventSystem.current.currentSelectedGameObject?.GetComponent