123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using SC.XR.Unity;
- using UnityEngine;
- using UnityEngine.UI;
- using XRTool.Util;
- public class PopUpInfo : RemoteSingleton<PopUpInfo>
- {
- 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 Text msgText
- {
- get
- {
- switch (pType)
- {
- case PopType.Tip:
- return UnityUtil.GetDepthChild<Text>(Tip.transform, "msgText");
- case PopType.Pop:
- return UnityUtil.GetDepthChild<Text>(Pop.transform, "msgText");
- case PopType.PopOk:
- return UnityUtil.GetDepthChild<Text>(PopOk.transform, "msgText");
- }
- return null;
- }
- }
- private Text btn1Text
- {
- get
- {
- switch (pType)
- {
- case PopType.Pop:
- return UnityUtil.GetDepthChild<Text>(Pop.transform, "btn1Text");
- case PopType.PopOk:
- return UnityUtil.GetDepthChild<Text>(PopOk.transform, "btn1Text");
- }
- return UnityUtil.GetDepthChild<Text>(Pop.transform, "btn1Text");
- }
- }
- private Text btn2Text
- {
- get
- {
- return UnityUtil.GetDepthChild<Text>(Pop.transform, "btn2Text");
- }
- }
- private Button btn1OK
- {
- get
- {
- switch (pType)
- {
- case PopType.Pop:
- return UnityUtil.GetDepthChild<Button>(Pop.transform, "btn1OK");
- case PopType.PopOk:
- return UnityUtil.GetDepthChild<Button>(PopOk.transform, "btn1OK");
- }
- return UnityUtil.GetDepthChild<Button>(Pop.transform, "btn1OK");
- }
- }
- private Button btn2Cancel
- {
- get
- {
- return UnityUtil.GetDepthChild<Button>(Pop.transform, "btn2Cancel");
- }
- }
- public void close()
- {
- Tip.SetActive(false);
- Pop.SetActive(false);
- PopOk.SetActive(false);
- }
- public void showTip()
- {
- Tip.SetActive(true);
- Pop.SetActive(false);
- PopOk.SetActive(false);
- ListenDlg.SetActive(false);
- TimerMgr.Instance.CreateTimer(()=> { Tip.SetActive(false); },2f);
- }
- public void showPop()
- {
- Tip.SetActive(false);
- PopOk.SetActive(false);
- Pop.SetActive(true);
- ListenDlg.SetActive(false);
- }
- public void showPopOk()
- {
- Tip.SetActive(false);
- Pop.SetActive(false);
- PopOk.SetActive(true);
- ListenDlg.SetActive(false);
- }
- public void showListenDlg()
- {
- Tip.SetActive(false);
- Pop.SetActive(false);
- PopOk.SetActive(false);
- ListenDlg.SetActive(true);
- }
- public void ShowNetErrorPanel()
- {
- NetErrorPanel.SetActive(true);
- }
- public void HideNetErrorPanel()
- {
- NetErrorPanel.SetActive(false);
- }
- }
|