Framework_YooAsset_HybridCLR/Assets/DemoGame/GameScript/Hotfix/UI/UIBase.cs

71 lines
1.6 KiB
C#

using UnityEngine;
namespace ZC
{
public abstract class UIBase : MonoBehaviour, IUI
{
private bool _isPause;
private bool _isActive;
private CanvasGroup _group;
private GameObjectBinding _uiGameObjectBinding;
public bool isPause => _isPause;
public bool isActive => _isActive;
public GameObject self => gameObject;
public GameObjectBinding uiGameObjectBinding => _uiGameObjectBinding;
private void Awake()
{
_group = GetComponent<CanvasGroup>();
_uiGameObjectBinding = GetComponent<GameObjectBinding>();
}
internal T GetValue<T>(string name) where T : Component
{
return _uiGameObjectBinding.GetValue<T>(name);
}
public virtual void OnInit()
{
_isPause = false;
_isActive = true;
}
public virtual void OnOpen()
{
gameObject.SetActive(true);
}
public void OnUpdate(float dateTime)
{
if (_isPause) return;
}
public virtual void OnClose()
{
gameObject.SetActive(false);
}
public virtual void OnPause()
{
_isPause = true;
_group.interactable = false;
}
public virtual void OnResume()
{
_isPause = false;
_group.interactable = true;
}
public virtual void OnDispose()
{
_isActive = false;
_isPause = true;
GameObject.Destroy(this.gameObject);
}
}
}