ErrorManager.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using TMPro;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. using XRTool.Util;
  8. public class ErrorManager : WindowSingleton<ErrorManager>
  9. {
  10. public Image iconBg;
  11. public RawImage icon;
  12. public TextMeshProUGUI TitleText;
  13. public TextMeshProUGUI MessageText;
  14. public TextMeshProUGUI actionText;
  15. public GameObject actionTextGO;
  16. public GameObject actionButtonGO;
  17. public GameObject BtGoAll;
  18. public TextMeshProUGUI bt0Text;
  19. public TextMeshProUGUI bt1Text;
  20. public TextMeshProUGUI bt2Text;
  21. int timeDjs = 0;
  22. Action<string> callback;
  23. List<string> backList;
  24. public void show(string title,string Msg,Color iconBg,Texture icon, List<string> backList, Action<string> callback, bool isText = true, string djsMsg="", int time=5,string bt0Name="",string bt1Name="",string bt2Name="")
  25. {
  26. this.gameObject.SetActive(true);
  27. TitleText.text = title;
  28. MessageText.text = Msg;
  29. actionText.text = "(" + time + ")" + djsMsg;
  30. this.iconBg.color = iconBg;
  31. this.icon.texture = icon;
  32. this.backList = backList;
  33. this.callback = callback;
  34. if (isText)
  35. {
  36. actionTextGO.gameObject.SetActive(true);
  37. actionButtonGO.gameObject.SetActive(false);
  38. timeDjs = time;
  39. TimerMgr.Instance.CreateTimer(()=> {
  40. timeDjs--;
  41. if(timeDjs<=0)
  42. {
  43. gotoBt(0);
  44. }
  45. actionText.text = "(" + timeDjs + ")" + djsMsg;
  46. },1, time);
  47. }else
  48. {
  49. actionTextGO.gameObject.SetActive(false);
  50. actionButtonGO.gameObject.SetActive(true);
  51. if (bt0Name!="")
  52. {
  53. bt0Text.text = bt0Name;
  54. bt0Text.transform.parent.gameObject.SetActive(true);
  55. bt1Text.transform.parent.gameObject.SetActive(false);
  56. bt2Text.transform.parent.gameObject.SetActive(false);
  57. }
  58. else
  59. {
  60. bt1Text.text = bt1Name;
  61. bt2Text.text = bt2Name;
  62. bt0Text.transform.parent.gameObject.SetActive(false);
  63. bt1Text.transform.parent.gameObject.SetActive(true);
  64. bt2Text.transform.parent.gameObject.SetActive(true);
  65. }
  66. }
  67. if(bt0Name == "" && bt1Name == "" && bt2Name == "" )
  68. {
  69. BtGoAll.SetActive(false);
  70. }
  71. else
  72. {
  73. BtGoAll.SetActive(true);
  74. }
  75. }
  76. public void gotoBt(int i)
  77. {
  78. callback.Invoke(backList[i]);
  79. this.gameObject.SetActive(false);
  80. WindowsManager.Instance.isShowTip = false;
  81. }
  82. }