ErrorManager.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. public TextMeshProUGUI xunJianText;
  22. public GameObject xunJianExit;
  23. int timeDjs = 0;
  24. Action<string> callback;
  25. List<string> backList;
  26. 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="")
  27. {
  28. this.gameObject.SetActive(true);
  29. TitleText.text = title;
  30. MessageText.text = Msg;
  31. xunJianExit.gameObject.SetActive(false);
  32. if (title == "Ѳ¼ìÏîÄ¿ÒÑÍê³É")
  33. {
  34. BtGoAll.SetActive(false);
  35. xunJianText.text = "(" + time + ")" + djsMsg;
  36. this.iconBg.color = iconBg;
  37. this.icon.texture = icon;
  38. this.backList = backList;
  39. this.callback = callback;
  40. if (isText)
  41. {
  42. xunJianText.gameObject.SetActive(true);
  43. actionButtonGO.gameObject.SetActive(false);
  44. timeDjs = time;
  45. TimerMgr.Instance.CreateTimer(() => {
  46. timeDjs--;
  47. if (timeDjs <= 0)
  48. {
  49. gotoBt(0);
  50. }
  51. xunJianText.text = "(" + timeDjs + ")" + djsMsg;
  52. }, 1, time);
  53. }
  54. else
  55. {
  56. actionTextGO.gameObject.SetActive(false);
  57. actionButtonGO.gameObject.SetActive(true);
  58. if (bt0Name != "")
  59. {
  60. bt0Text.text = bt0Name;
  61. bt0Text.transform.parent.gameObject.SetActive(true);
  62. bt1Text.transform.parent.gameObject.SetActive(false);
  63. bt2Text.transform.parent.gameObject.SetActive(false);
  64. }
  65. else
  66. {
  67. bt1Text.text = bt1Name;
  68. bt2Text.text = bt2Name;
  69. bt0Text.transform.parent.gameObject.SetActive(false);
  70. bt1Text.transform.parent.gameObject.SetActive(true);
  71. bt2Text.transform.parent.gameObject.SetActive(true);
  72. }
  73. }
  74. if (bt0Name == "" && bt1Name == "" && bt2Name == "")
  75. {
  76. xunJianExit.SetActive(false);
  77. }
  78. else
  79. {
  80. xunJianExit.SetActive(true);
  81. }
  82. }
  83. else
  84. {
  85. actionText.text = "(" + time + ")" + djsMsg;
  86. this.iconBg.color = iconBg;
  87. this.icon.texture = icon;
  88. this.backList = backList;
  89. this.callback = callback;
  90. if (isText)
  91. {
  92. actionTextGO.gameObject.SetActive(true);
  93. actionButtonGO.gameObject.SetActive(false);
  94. timeDjs = time;
  95. TimerMgr.Instance.CreateTimer(() => {
  96. timeDjs--;
  97. if (timeDjs <= 0)
  98. {
  99. gotoBt(0);
  100. }
  101. actionText.text = "(" + timeDjs + ")" + djsMsg;
  102. }, 1, time);
  103. }
  104. else
  105. {
  106. actionTextGO.gameObject.SetActive(false);
  107. actionButtonGO.gameObject.SetActive(true);
  108. if (bt0Name != "")
  109. {
  110. bt0Text.text = bt0Name;
  111. bt0Text.transform.parent.gameObject.SetActive(true);
  112. bt1Text.transform.parent.gameObject.SetActive(false);
  113. bt2Text.transform.parent.gameObject.SetActive(false);
  114. }
  115. else
  116. {
  117. bt1Text.text = bt1Name;
  118. bt2Text.text = bt2Name;
  119. bt0Text.transform.parent.gameObject.SetActive(false);
  120. bt1Text.transform.parent.gameObject.SetActive(true);
  121. bt2Text.transform.parent.gameObject.SetActive(true);
  122. }
  123. }
  124. if (bt0Name == "" && bt1Name == "" && bt2Name == "")
  125. {
  126. BtGoAll.SetActive(false);
  127. }
  128. else
  129. {
  130. BtGoAll.SetActive(true);
  131. }
  132. }
  133. }
  134. public void gotoBt(int i)
  135. {
  136. callback.Invoke(backList[i]);
  137. this.gameObject.SetActive(false);
  138. WindowsManager.Instance.isShowTip = false;
  139. }
  140. }