ScenesManager.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. ShowDevice = 6,
  16. Navigationing = 8,
  17. officeInt = 30,
  18. RoomInt = 40,
  19. publicInt = 50,
  20. }
  21. public void showOffice(SceneType stype)
  22. {
  23. if(dlglist.ContainsKey(mType.officeInt.GetHashCode()))
  24. for (int i = 0; i < dlglist[mType.officeInt.GetHashCode()].Count; i++)
  25. {
  26. if (stype == dlglist[mType.officeInt.GetHashCode()][i]._sceneType)
  27. {
  28. dlglist[mType.officeInt.GetHashCode()][i].gameObject.SetActive(true);
  29. MonoBehaviour alist = dlglist[mType.officeInt.GetHashCode()][i].GetComponent<MonoBehaviour>();
  30. Type t = Type.GetType(alist.name);
  31. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  32. if (md != null)
  33. {
  34. md.Invoke(alist, null);
  35. }
  36. }
  37. else
  38. {
  39. dlglist[mType.officeInt.GetHashCode()][i].gameObject.SetActive(false);
  40. }
  41. }
  42. }
  43. public enum SceneType
  44. {
  45. GameStartLogo = 10001,
  46. ShowLogin = 20001,
  47. ShowChoose = 30001,
  48. ShowXunJian = 40001,
  49. ShowXJ = 41001,
  50. ShowDH = 41002,
  51. ShowRTC = 50001,
  52. ShowRTCHistory = 51002,
  53. //ShowZhiDao = 50001,
  54. ShowDevice = 60001, // 设备基础信息
  55. ShowBasicDevice = 61001, // 设备基础详情
  56. DeviceDetails = 61002, // 设备详情
  57. Navigationing = 80001, // 导航中
  58. ShowOffice = 300001,
  59. CreateRoom = 300101,
  60. JoinRoom = 300102,
  61. UserSystem = 300103,
  62. RemoteSystem = 300104,
  63. OfficeWindow = 300105,
  64. ShowRoom = 400001,
  65. RoomMain = 400101,
  66. RoomOtherUser = 400102,
  67. RoomInfo = 400103,
  68. RoomFile = 400104,
  69. PopPublic = 500001,
  70. PopPeerView = 500101,
  71. PopUpInfo = 500101,
  72. PopCall = 500102,
  73. }
  74. private static ScenesManager instance;
  75. public static ScenesManager Instance
  76. {
  77. get
  78. {
  79. if (instance == null)
  80. {
  81. instance = new ScenesManager();
  82. }
  83. return instance;
  84. }
  85. }
  86. public List<SceneInfo> windows = new List<SceneInfo>();
  87. public Dictionary<int, List<SceneInfo>> dlglist = new Dictionary<int, List<SceneInfo>>();
  88. public void initWindow(GameObject window)
  89. {
  90. SceneInfo sceneInfo = window.AddComponent<SceneInfo>();
  91. SceneType stp = (SceneType)System.Enum.Parse(typeof(SceneType), window.name.Split('(')[0]);
  92. sceneInfo.setType(stp);
  93. int codeint = stp.GetHashCode() / 10000;
  94. if (stp.GetHashCode() - (codeint * 10000) == 1)
  95. {
  96. windows.Add(sceneInfo);
  97. // window.SetActive(false);
  98. }
  99. else
  100. {
  101. if (dlglist.ContainsKey(codeint))
  102. {
  103. List<SceneInfo> dlg = dlglist[codeint];
  104. dlg.Add(sceneInfo);
  105. dlglist[codeint] = dlg;
  106. }
  107. else
  108. {
  109. List<SceneInfo> dlg = new List<SceneInfo>();
  110. dlg.Add(sceneInfo);
  111. dlglist.Add(codeint, dlg);
  112. }
  113. }
  114. }
  115. public void initRoom()
  116. {
  117. Debug.Log("HJJLANGCHAORTC " + mType.RoomInt.GetHashCode());
  118. for (int i = 0; i < dlglist[mType.RoomInt.GetHashCode()].Count; i++)
  119. {
  120. MonoBehaviour alist = dlglist[mType.RoomInt.GetHashCode()][i].GetComponent<MonoBehaviour>();
  121. Debug.Log("HJJLANGCHAORTC " + alist.name);
  122. Type t = Type.GetType(alist.name);
  123. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  124. if (md != null)
  125. {
  126. md.Invoke(alist, null);
  127. }
  128. }
  129. }
  130. public void showWindow(SceneType sceneType)
  131. {
  132. for (int i = 0; i < windows.Count; i++)
  133. {
  134. int codeint = windows[i]._sceneType.GetHashCode() / 10000;
  135. if (windows[i]._sceneType == sceneType || codeint == mType.publicInt.GetHashCode())
  136. {
  137. windows[i].gameObject.SetActive(true);
  138. MonoBehaviour alist = windows[i].GetComponent<MonoBehaviour>();
  139. Type t = Type.GetType(alist.name);
  140. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  141. if (md != null)
  142. {
  143. md.Invoke(alist, null);
  144. }
  145. }
  146. else
  147. {
  148. windows[i].gameObject.SetActive(false);
  149. }
  150. }
  151. }
  152. public void initPopUp()
  153. {
  154. // for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
  155. // {
  156. // dlglist[mType.publicInt.GetHashCode()][i].gameObject.SetActive(false);
  157. // }
  158. }
  159. private PopPublic _popPublic;
  160. public PopPublic popPublic
  161. {
  162. get
  163. {
  164. if (!_popPublic)
  165. {
  166. for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
  167. {
  168. PopPublic ppc = dlglist[mType.publicInt.GetHashCode()][i].GetComponent<PopPublic>();
  169. if (ppc)
  170. _popPublic = ppc;
  171. }
  172. }
  173. return _popPublic;
  174. }
  175. }
  176. public void showPop()
  177. {
  178. popPublic.gameObject.SetActive(true);
  179. }
  180. }