ScenesManager.cs 5.6 KB

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