using System; using UnityEngine; namespace ZC { [AttributeUsage(AttributeTargets.Class)] class UITypeAttribute : Attribute { public UIType UIType { get; set; } public UITypeAttribute(UIType uiType) { UIType = uiType; } } public abstract class UIBase : MonoBehaviour, IUI { private bool _isPause = true; private bool _isActive = false; private CanvasGroup _group; public bool isPause => _isPause; public bool isActive => _isActive; public GameObject self => this.gameObject; protected GameObjectBinding _uiGameObjectBinding; #region Mono private void Awake() { _uiGameObjectBinding = GetComponent(); } private void OnDestroy() { } #endregion internal T GetValue(string name) where T : Component { return _uiGameObjectBinding.GetValue(name); } public virtual void Init() { _isPause = false; _isActive = true; } public virtual void Open() { transform.localScale = Vector3.one; } public virtual void OnUpdate(float dateTime) { if (_isPause) return; } public virtual void Close() { transform.localScale = Vector3.zero; } public virtual void Pause() { _isPause = true; _group.interactable = false; } public virtual void Resume() { _isPause = false; _group.interactable = true; } public virtual void Dispose() { _isActive = false; _isPause = true; DestroyImmediate(this.gameObject); } } }