43 lines
946 B
C#
43 lines
946 B
C#
using UnityEngine;
|
|
|
|
namespace HK
|
|
{
|
|
public abstract class UIItemBase : MonoBehaviour
|
|
{
|
|
private GameObjectBinding _uiGameObjectBinding;
|
|
|
|
public Transform self => gameObject.transform;
|
|
|
|
public GameObjectBinding uiGameObjectBinding => _uiGameObjectBinding;
|
|
|
|
private void Awake()
|
|
{
|
|
_uiGameObjectBinding = GetComponent<GameObjectBinding>();
|
|
OnInit();
|
|
}
|
|
|
|
internal T GetValue<T>(string name) where T : Component
|
|
{
|
|
return _uiGameObjectBinding.GetValue<T>(name);
|
|
}
|
|
|
|
public virtual void OnInit()
|
|
{
|
|
}
|
|
|
|
public virtual void OnShow()
|
|
{
|
|
gameObject.SetActive(true);
|
|
}
|
|
|
|
public virtual void OnHide()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
public virtual void OnDispose()
|
|
{
|
|
GameObject.Destroy(this.gameObject);
|
|
}
|
|
}
|
|
} |