ProjectDDD/Assets/_DDD/_Scripts/GameUi/BasePopupUi.cs

38 lines
1.1 KiB
C#
Raw Normal View History

2025-07-29 15:56:47 +00:00
using UnityEngine;
using UnityEngine.EventSystems;
namespace DDD
{
public abstract class BasePopupUi : BaseUi
{
public abstract InputActionMaps InputActionMaps { get; }
2025-07-29 15:56:47 +00:00
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());
}
}
2025-08-05 04:00:01 +00:00
public virtual void Open(OpenPopupUiEvent evt)
2025-07-29 15:56:47 +00:00
{
2025-08-05 04:00:01 +00:00
base.OpenPanel();
2025-07-29 15:56:47 +00:00
EventSystem.current.SetSelectedGameObject(GetInitialSelected());
}
2025-08-05 04:00:01 +00:00
public virtual void Close()
{
var evt = GameEvents.ClosePopupUiEvent;
evt.UiType = GetType();
EventBus.Broadcast(evt);
}
}
}