ScenesManager.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using SC.XR.Unity;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. public class ScenesManager
  7. {
  8. public enum mType
  9. {
  10. LogoInt = 1,
  11. LoginInt = 2,
  12. ShowChoose = 3,
  13. ShowXunJian = 4,
  14. ShowRTC = 5,
  15. ShowZhiDao = 6,
  16. publicInt = 7,
  17. DeviceInfo = 8,
  18. Navigationing = 9,
  19. }
  20. public enum SceneType
  21. {
  22. GameStartLogo = 10001,
  23. ShowLogin = 20001,
  24. ShowChoose = 30001,
  25. ShowXunJian = 40001,
  26. ShowXJ = 41001,
  27. ShowDH = 41002,
  28. ShowRTC = 50001,
  29. ShowRTCHistory = 51002,
  30. //ShowZhiDao = 50001,
  31. ShowDevice = 60001, // 设备信息
  32. DeviceDetails = 61002, // 设备详情
  33. Navigationing = 80001, // 导航中
  34. PopPublic = 70001,
  35. }
  36. private static ScenesManager instance;
  37. public static ScenesManager Instance
  38. {
  39. get
  40. {
  41. if (instance == null)
  42. {
  43. instance = new ScenesManager();
  44. }
  45. return instance;
  46. }
  47. }
  48. public List<SceneInfo> windows = new List<SceneInfo>();
  49. public Dictionary<int, List<SceneInfo>> dlglist = new Dictionary<int, List<SceneInfo>>();
  50. public void initWindow(GameObject window)
  51. {
  52. SceneInfo sceneInfo = window.AddComponent<SceneInfo>();
  53. SceneType stp = (SceneType)System.Enum.Parse(typeof(SceneType), window.name.Split('(')[0]);
  54. sceneInfo.setType(stp);
  55. int codeint = stp.GetHashCode() / 10000;
  56. if (stp.GetHashCode() - (codeint * 10000) == 1)
  57. {
  58. windows.Add(sceneInfo);
  59. // window.SetActive(false);
  60. }
  61. else
  62. {
  63. if (dlglist.ContainsKey(codeint))
  64. {
  65. List<SceneInfo> dlg = dlglist[codeint];
  66. dlg.Add(sceneInfo);
  67. dlglist[codeint] = dlg;
  68. }
  69. else
  70. {
  71. List<SceneInfo> dlg = new List<SceneInfo>();
  72. dlg.Add(sceneInfo);
  73. dlglist.Add(codeint, dlg);
  74. }
  75. }
  76. }
  77. public void showWindow(SceneType sceneType)
  78. {
  79. for (int i = 0; i < windows.Count; i++)
  80. {
  81. int codeint = windows[i]._sceneType.GetHashCode() / 10000;
  82. if (windows[i]._sceneType == sceneType || codeint == mType.publicInt.GetHashCode())
  83. {
  84. windows[i].gameObject.SetActive(true);
  85. MonoBehaviour alist = windows[i].GetComponent<MonoBehaviour>();
  86. Type t = Type.GetType(alist.name);
  87. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  88. if (md != null)
  89. {
  90. md.Invoke(alist, null);
  91. }
  92. }
  93. else
  94. {
  95. windows[i].gameObject.SetActive(false);
  96. }
  97. }
  98. }
  99. public void initPopUp()
  100. {
  101. for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
  102. {
  103. dlglist[mType.publicInt.GetHashCode()][i].gameObject.SetActive(false);
  104. }
  105. }
  106. private PopPublic _popPublic;
  107. public PopPublic popPublic
  108. {
  109. get
  110. {
  111. if (!_popPublic)
  112. {
  113. for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
  114. {
  115. PopPublic ppc = dlglist[mType.publicInt.GetHashCode()][i].GetComponent<PopPublic>();
  116. if (ppc)
  117. _popPublic = ppc;
  118. }
  119. }
  120. return _popPublic;
  121. }
  122. }
  123. public void showPop()
  124. {
  125. popPublic.gameObject.SetActive(true);
  126. }
  127. }