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(); _uiGameObjectBinding = GetComponent(); } internal T GetValue(string name) where T : Component { return _uiGameObjectBinding.GetValue(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); } } }