ProjectDDD/Assets/_DDD/_Scripts/GameUi/BasePopupUi.cs
2025-08-05 13:00:01 +09:00

38 lines
1.1 KiB
C#

using UnityEngine;
using UnityEngine.EventSystems;
namespace DDD
{
public abstract class BasePopupUi : BaseUi
{
public abstract InputActionMaps InputActionMaps { get; }
protected abstract GameObject GetInitialSelected();
protected override void Update()
{
base.Update();
var currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
if (!currentSelectedGameObject || currentSelectedGameObject.activeInHierarchy == false)
{
if (!GetInitialSelected()) return;
EventSystem.current.SetSelectedGameObject(GetInitialSelected());
}
}
public virtual void Open(OpenPopupUiEvent evt)
{
base.OpenPanel();
EventSystem.current.SetSelectedGameObject(GetInitialSelected());
}
public virtual void Close()
{
var evt = GameEvents.ClosePopupUiEvent;
evt.UiType = GetType();
EventBus.Broadcast(evt);
}
}
}