_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Scene_shop/BaseUIPanel.cs
2024-11-25 23:31:50 +08:00

49 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
//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()
{
HidePanel();
CloseBTN.onClick.AddListener(()=> {
HidePanel();
});
}
/// <summary>
/// 显示面板,可以重写
/// </summary>
public virtual void ShopPanel()
{
Panel.gameObject.SetActive(true);
CloseBTN.gameObject.SetActive(true);
Panel.transform.DOScale(1f, 0.3f);
}
/// <summary>
/// 隐藏面板,可以重写
/// </summary>
public virtual void HidePanel()
{
Panel.transform.DOScale(0.5f,0.2f);
CloseBTN.gameObject.SetActive(false);
Panel.gameObject.SetActive(false);
}
}