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

88 lines
1.8 KiB
C#

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<GameObjectBinding>();
}
private void OnDestroy()
{
}
#endregion
internal T GetValue<T>(string name) where T : Component
{
return _uiGameObjectBinding.GetValue<T>(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);
}
}
}