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.
65 lines
1.5 KiB
65 lines
1.5 KiB
8 months ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
using TMPro;
|
||
|
using System;
|
||
|
|
||
|
public class TipPanelManager : MonoBehaviour
|
||
|
{
|
||
|
public TextMeshProUGUI showText;
|
||
|
public Button sureBtn;
|
||
|
public Button cancelBtn;
|
||
|
private static TipPanelManager instance;
|
||
|
|
||
|
private Action sureAction;
|
||
|
private Action cancelAction;
|
||
|
|
||
|
private TipPanelManager()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
void Start()
|
||
|
{
|
||
|
sureBtn.onClick.AddListener(sureBtn_Click);
|
||
|
cancelBtn.onClick.AddListener(cancelBtn_Click);
|
||
|
}
|
||
|
|
||
|
private void cancelBtn_Click()
|
||
|
{
|
||
|
if (cancelAction != null)
|
||
|
cancelAction.Invoke();
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
private void sureBtn_Click()
|
||
|
{
|
||
|
if (sureAction != null)
|
||
|
sureAction.Invoke();
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
public void Show(string tips, Action sure = null, Action cancel = null)
|
||
|
{
|
||
|
showText.text = tips;
|
||
|
sureAction = sure;
|
||
|
cancelAction = cancel;
|
||
|
transform.SetAsLastSibling();
|
||
|
gameObject.SetActive(true);
|
||
|
}
|
||
|
public static TipPanelManager GetInstance
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (instance == null)
|
||
|
{
|
||
|
var obj = Resources.Load<GameObject>("TipPanel");
|
||
|
var tips = Instantiate(obj, GameObject.Find("Canvas").transform);
|
||
|
tips.name = "TipPanel";
|
||
|
instance = tips.GetComponent<TipPanelManager>();
|
||
|
}
|
||
|
return instance;
|
||
|
}
|
||
|
}
|
||
|
}
|