ScenesManager.cs 3.6 KB

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