using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class WarningPopPanel : MonoBehaviour { [Header("关闭")] public Button closeBtn; [Header("显示文本")] public Text showText; // Start is called before the first frame update void Start() { closeBtn.onClick.AddListener(() => { ClosePanel(); }); } // Update is called once per frame void Update() { } //打开面板 public void OpenPanel(string needText) { transform.gameObject.SetActive(true); showText.text = needText; } //关闭面板 public void ClosePanel() { showText.text = ""; transform.gameObject.SetActive(false); } }