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

47 lines
1.3 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();
2025-08-14 10:39:27 +00:00
protected override void Awake()
{
base.Awake();
_enableBlockImage = true;
}
2025-07-29 15:56:47 +00:00
protected override void Update()
{
base.Update();
2025-08-17 07:23:05 +00:00
if (IsOpenPanel() == false) return;
2025-07-29 15:56:47 +00:00
var currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
if (currentSelectedGameObject == null || currentSelectedGameObject.activeInHierarchy == false)
2025-07-29 15:56:47 +00:00
{
if (GetInitialSelected() == null) return;
2025-07-29 15:56:47 +00:00
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);
}
}
}