72 lines
1.5 KiB
C#
72 lines
1.5 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using DG.Tweening;
|
||
using System.Threading.Tasks;
|
||
|
||
//panel基类,主要用于panel的显示和隐藏
|
||
//初始化会隐藏Panel
|
||
//请将panel挂载一个空节点上,将这个脚本放空节点
|
||
public class BaseUIPanel : Base
|
||
{
|
||
[Header("显示隐藏的面板,根据重写,可以不给")]
|
||
public GameObject Panel;
|
||
|
||
[Header("CloseBTN,根据重写,可以不给")]
|
||
public Button CloseBTN;
|
||
// Start is called before the first frame update
|
||
public virtual void Start()
|
||
{
|
||
|
||
if (Panel!=null)
|
||
{
|
||
HidePanel();
|
||
}
|
||
|
||
if (CloseBTN!=null)
|
||
{
|
||
CloseBTN.onClick.AddListener(() => {
|
||
HidePanel();
|
||
});
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 显示面板,可以重写
|
||
/// </summary>
|
||
public virtual void ShopPanel()
|
||
{
|
||
Panel.gameObject.SetActive(true);
|
||
if (CloseBTN != null)
|
||
{
|
||
CloseBTN.gameObject.SetActive(false);
|
||
}
|
||
Panel.transform.DOScale(1f, 0.3f);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 隐藏面板,可以重写
|
||
/// </summary>
|
||
public virtual async Task HidePanel()
|
||
{
|
||
Panel.transform.DOScale(0.5f,0.2f);
|
||
if (CloseBTN != null)
|
||
{
|
||
CloseBTN.gameObject.SetActive(false);
|
||
}
|
||
Panel.gameObject.SetActive(false);
|
||
await Task.Delay(200);
|
||
|
||
}
|
||
public async void closure()
|
||
{
|
||
await HidePanel();
|
||
Destroy(gameObject);
|
||
|
||
}
|
||
}
|