ScenesManager.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. ShowBasicDevice = 61001, // 设备基础详情
  33. DeviceDetails = 61002, // 设备详情
  34. Navigationing = 80001, // 导航中
  35. PopPublic = 70001,
  36. }
  37. private static ScenesManager instance;
  38. public static ScenesManager Instance
  39. {
  40. get
  41. {
  42. if (instance == null)
  43. {
  44. instance = new ScenesManager();
  45. }
  46. return instance;
  47. }
  48. }
  49. public List<SceneInfo> windows = new List<SceneInfo>();
  50. public Dictionary<int, List<SceneInfo>> dlglist = new Dictionary<int, List<SceneInfo>>();
  51. public void initWindow(GameObject window)
  52. {
  53. SceneInfo sceneInfo = window.AddComponent<SceneInfo>();
  54. SceneType stp = (SceneType)System.Enum.Parse(typeof(SceneType), window.name.Split('(')[0]);
  55. sceneInfo.setType(stp);
  56. int codeint = stp.GetHashCode() / 10000;
  57. if (stp.GetHashCode() - (codeint * 10000) == 1)
  58. {
  59. windows.Add(sceneInfo);
  60. // window.SetActive(false);
  61. }
  62. else
  63. {
  64. if (dlglist.ContainsKey(codeint))
  65. {
  66. List<SceneInfo> dlg = dlglist[codeint];
  67. dlg.Add(sceneInfo);
  68. dlglist[codeint] = dlg;
  69. }
  70. else
  71. {
  72. List<SceneInfo> dlg = new List<SceneInfo>();
  73. dlg.Add(sceneInfo);
  74. dlglist.Add(codeint, dlg);
  75. }
  76. }
  77. }
  78. public void showWindow(SceneType sceneType)
  79. {
  80. for (int i = 0; i < windows.Count; i++)
  81. {
  82. int codeint = windows[i]._sceneType.GetHashCode() / 10000;
  83. if (windows[i]._sceneType == sceneType || codeint == mType.publicInt.GetHashCode())
  84. {
  85. windows[i].gameObject.SetActive(true);
  86. MonoBehaviour alist = windows[i].GetComponent<MonoBehaviour>();
  87. Type t = Type.GetType(alist.name);
  88. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  89. if (md != null)
  90. {
  91. md.Invoke(alist, null);
  92. }
  93. }
  94. else
  95. {
  96. windows[i].gameObject.SetActive(false);
  97. }
  98. }
  99. }
  100. public void initPopUp()
  101. {
  102. for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
  103. {
  104. dlglist[mType.publicInt.GetHashCode()][i].gameObject.SetActive(false);
  105. }
  106. }
  107. private PopPublic _popPublic;
  108. public PopPublic popPublic
  109. {
  110. get
  111. {
  112. if (!_popPublic)
  113. {
  114. for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
  115. {
  116. PopPublic ppc = dlglist[mType.publicInt.GetHashCode()][i].GetComponent<PopPublic>();
  117. if (ppc)
  118. _popPublic = ppc;
  119. }
  120. }
  121. return _popPublic;
  122. }
  123. }
  124. public void showPop()
  125. {
  126. popPublic.gameObject.SetActive(true);
  127. }
  128. }