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

45 lines
1.2 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 Awake()
{
base.Awake();
_enableBlockImage = true;
}
protected override void Update()
{
base.Update();
var currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
if (currentSelectedGameObject == null || currentSelectedGameObject.activeInHierarchy == false)
{
if (GetInitialSelected() == null) 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);
}
}
}