网上演练贵港万达广场(人员密集)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.4 KiB

4 years ago
using System;
using UnityEngine;
public abstract class UIView : MonoBehaviour
{
//UIView名字
public string ViewName { get; set; }
public abstract UIViewType ViewType { get; }
public Action<UIView> OnShow;
public Action<UIView> OnHide;
public int Z_Index
{
get
{
return transform.GetSiblingIndex();
}
set
{
transform.SetSiblingIndex(value);
}
}
public virtual void Show()
{
//transform.GetSiblingIndex
//没有显示的情况下才显示
if (!gameObject.activeSelf)
{
gameObject.SetActive(true);
if (OnShow != null)
{
OnShow(this);
}
// 设置层级到最上层
transform.SetAsLastSibling();
// 刷新
Refresh();
}
}
public virtual void Hide()
{
//显示的情况下才隐藏
if (gameObject!=null&&gameObject.activeSelf)
{
gameObject.SetActive(false);
if (OnHide != null)
{
OnHide(this);
}
}
}
public virtual void Refresh()
{
}
//页面销毁是通知UIManager自己销毁了
public virtual void OnDestroy()
{
OnShow = null;
OnHide = null;
UIManager.DestroyView(ViewName);
}
}
public enum UIViewType
{
Normal,
Popup
}