using System; using System.Collections; using System.Collections.Generic; using SC.XR.Unity; using UnityEngine; using UnityEngine.UI; using XRTool.Util; using TMPro; public class PopUpInfo : RemoteSingleton { public GameObject NetErrorPanel; public enum PopType { Tip=1, Pop = 2, PopOk = 3, ListenDlg=4 } public void Start() { NetErrorPanel.SetActive(false); Tip.SetActive(false); Pop.SetActive(false); PopOk.SetActive(false); ListenDlg.SetActive(false); } public GameObject Tip; public GameObject Pop; public GameObject PopOk; public GameObject ListenDlg; private PopType pType; public void showPublic(PopType popType) { pType = popType; switch (popType) { case PopType.Tip: showTip(); break; case PopType.Pop: showPop(); break; case PopType.PopOk: showPopOk(); break; case PopType.ListenDlg: showListenDlg(); break; } } public void showPublic(PopType popType,string msg, string b1 = "确定", Action ok = null, string b2 = "取消", Action cancel = null) { btn1OK.onClick.RemoveAllListeners(); btn2Cancel.onClick.RemoveAllListeners(); pType = popType; msgText.text = msg; btn1Text.text = b1; btn2Text.text = b2; btn1OK.onClick.AddListener(() => { close(); if (ok!=null) ok.Invoke(); } ); btn2Cancel.onClick.AddListener(() => { close(); if (cancel!=null) cancel.Invoke(); }); switch (popType) { case PopType.Tip: showTip(); break; case PopType.Pop: showPop(); break; case PopType.PopOk: showPopOk(); break; } } private TMP_Text msgText { get { switch (pType) { case PopType.Tip: return UnityUtil.GetDepthChild(Tip.transform, "msgText"); case PopType.Pop: return UnityUtil.GetDepthChild(Pop.transform, "msgText"); case PopType.PopOk: return UnityUtil.GetDepthChild(PopOk.transform, "msgText"); } return null; } } private TMP_Text btn1Text { get { switch (pType) { case PopType.Pop: return UnityUtil.GetDepthChild(Pop.transform, "btn1Text"); case PopType.PopOk: return UnityUtil.GetDepthChild(PopOk.transform, "btn1Text"); } return UnityUtil.GetDepthChild(Pop.transform, "btn1Text"); } } private TMP_Text btn2Text { get { return UnityUtil.GetDepthChild(Pop.transform, "btn2Text"); } } private Button btn1OK { get { switch (pType) { case PopType.Pop: return UnityUtil.GetDepthChild