2025-07-29 15:56:47 +00:00
|
|
|
using System;
|
2025-07-21 07:53:39 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace DDD
|
|
|
|
{
|
|
|
|
public abstract class BaseUi : MonoBehaviour
|
|
|
|
{
|
2025-08-05 05:14:39 +00:00
|
|
|
protected CanvasGroup _canvasGroup;
|
2025-08-14 10:39:27 +00:00
|
|
|
protected GameObject _blockImage;
|
2025-07-22 07:46:37 +00:00
|
|
|
protected GameObject _panel;
|
2025-07-21 07:53:39 +00:00
|
|
|
public virtual bool IsBlockingTime => false;
|
2025-07-23 03:24:52 +00:00
|
|
|
public virtual bool IsOpen => _panel.activeSelf;
|
2025-07-22 07:46:37 +00:00
|
|
|
|
2025-08-14 10:39:27 +00:00
|
|
|
[SerializeField] protected bool _enableBlockImage;
|
|
|
|
|
2025-07-22 07:46:37 +00:00
|
|
|
protected virtual void Awake()
|
|
|
|
{
|
2025-08-05 05:14:39 +00:00
|
|
|
_canvasGroup = GetComponent<CanvasGroup>();
|
2025-07-22 07:46:37 +00:00
|
|
|
_panel = transform.Find(CommonConstants.Panel).gameObject;
|
2025-08-14 10:39:27 +00:00
|
|
|
_blockImage = transform.Find(CommonConstants.BlockImage).gameObject;
|
2025-07-22 07:46:37 +00:00
|
|
|
}
|
2025-08-14 08:21:17 +00:00
|
|
|
|
|
|
|
protected virtual void OnEnable()
|
|
|
|
{
|
2025-08-14 10:39:27 +00:00
|
|
|
|
2025-08-14 08:21:17 +00:00
|
|
|
}
|
2025-08-14 10:39:27 +00:00
|
|
|
|
2025-07-21 07:53:39 +00:00
|
|
|
protected virtual void Start()
|
|
|
|
{
|
|
|
|
TryRegister();
|
2025-08-05 04:00:01 +00:00
|
|
|
ClosePanel();
|
2025-07-21 07:53:39 +00:00
|
|
|
}
|
|
|
|
|
2025-07-29 15:56:47 +00:00
|
|
|
protected virtual void Update()
|
|
|
|
{
|
2025-08-14 10:39:27 +00:00
|
|
|
|
2025-07-29 15:56:47 +00:00
|
|
|
}
|
|
|
|
|
2025-08-14 08:21:17 +00:00
|
|
|
protected virtual void OnDisable()
|
|
|
|
{
|
2025-08-14 10:39:27 +00:00
|
|
|
|
2025-08-14 08:21:17 +00:00
|
|
|
}
|
|
|
|
|
2025-07-21 07:53:39 +00:00
|
|
|
protected virtual void OnDestroy()
|
|
|
|
{
|
|
|
|
TryUnregister();
|
|
|
|
}
|
2025-08-14 10:39:27 +00:00
|
|
|
|
2025-07-21 07:53:39 +00:00
|
|
|
protected virtual void TryRegister() { }
|
|
|
|
protected virtual void TryUnregister() { }
|
|
|
|
|
2025-08-14 10:39:27 +00:00
|
|
|
public virtual void OpenPanel()
|
|
|
|
{
|
|
|
|
if (_enableBlockImage)
|
|
|
|
{
|
|
|
|
_blockImage.SetActive(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
_panel.SetActive(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void ClosePanel()
|
|
|
|
{
|
|
|
|
if (_enableBlockImage)
|
|
|
|
{
|
|
|
|
_blockImage.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
_panel.SetActive(false);
|
|
|
|
}
|
2025-08-05 05:14:39 +00:00
|
|
|
|
|
|
|
public virtual void SetUiInteractable(bool active)
|
|
|
|
{
|
|
|
|
_canvasGroup.interactable = active;
|
|
|
|
_canvasGroup.blocksRaycasts = active;
|
|
|
|
}
|
2025-08-17 07:23:05 +00:00
|
|
|
|
|
|
|
public bool IsOpenPanel() => _panel.activeInHierarchy;
|
2025-07-21 07:53:39 +00:00
|
|
|
}
|
|
|
|
}
|