using UnityEngine; using UnityEngine.EventSystems; namespace DDD { public abstract class BasePopupUi : BaseUi { public bool IsTopPopup => UiManager.Instance.UiState.IsTopPopup(this); public InputActionMaps InputActionMaps { get; protected set; } protected override void Awake() { base.Awake(); // BasePopupUi의 기본값 적용 _enableBlockImage = true; } protected override void OnEnable() { base.OnEnable(); } protected override void Update() { base.Update(); // BasePopupUi의 Update 로직 구현 if (IsOpenPanel() == false || IsInitialized == false) return; var currentSelectedGameObject = EventSystem.current.currentSelectedGameObject; if (!currentSelectedGameObject || currentSelectedGameObject.activeInHierarchy == false) { var initialSelected = GetInitialSelected(); if (initialSelected) { EventSystem.current.SetSelectedGameObject(initialSelected); } } } protected override void TryRegister() { base.TryRegister(); UiManager.Instance.UiState.RegisterPopupUI(this); } protected override void TryUnregister() { base.TryUnregister(); UiManager.Instance?.UiState?.UnregisterPopupUI(this); } public virtual void Open(OpenPopupUiEvent evt) { OpenPanel(); var initialSelected = GetInitialSelected(); if (initialSelected != null) { EventSystem.current.SetSelectedGameObject(initialSelected); } transform.SetAsLastSibling(); } public virtual void Close() { var evt = GameEvents.ClosePopupUiEvent; evt.UiType = GetType(); EventBus.Broadcast(evt); } protected abstract GameObject GetInitialSelected(); } }