HomeMgr.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using JCUnityLib;
  5. /* Home场景管理者 */
  6. public class HomeMgr : MonoBehaviour
  7. {
  8. public static HomeMgr ins;
  9. void Awake()
  10. {
  11. ins = this;
  12. PersistenHandler.Init();
  13. ViewMgr.Instance.ShowView<TopBarView>();
  14. ViewMgr.Instance.ShowView<HomeView>();
  15. ViewMgr.Instance.ShowView<HomeFrameView>();
  16. Instantiate(SceneResourceManager.Instance.GetPrefab("DeviceBatteryView"));
  17. Instantiate(SceneResourceManager.Instance.GetPrefab("AuthLoginMask"));
  18. Instantiate(SceneResourceManager.Instance.GetPrefab("RenderBowCamera"));
  19. Instantiate(SceneResourceManager.Instance.GetPrefab("NewUserGuiderManager"));
  20. //标记某些界面不需要销毁
  21. ViewMgr.Instance.SetViewDontDestroy<GameStartView>();
  22. ViewMgr.Instance.SetViewDontDestroy<ChallengeOptionView>();
  23. ViewMgr.Instance.SetViewDontDestroy<RoleSelectView>();
  24. ViewMgr.Instance.SetViewDontDestroy<PKGameOptionView>();
  25. ViewMgr.Instance.SetViewDontDestroy<PKMatchView>();
  26. //显示缓存的隐藏页面
  27. ViewMgr.Instance.ResumeView<GameStartView>();
  28. ViewMgr.Instance.ResumeView<ChallengeOptionView>();
  29. ViewMgr.Instance.ResumeView<RoleSelectView>();
  30. ViewMgr.Instance.ResumeView<PKGameOptionView>();
  31. ViewMgr.Instance.ResumeView<PKMatchView>();
  32. }
  33. void Start()
  34. {
  35. UserPlayer.ConnectServer();
  36. }
  37. void OnDestroy()
  38. {
  39. if (ins == this) ins = null;
  40. ViewMgr.Instance.DestroyAllViewsExcludeDontDestroy();
  41. //隐藏可缓存的页面
  42. ViewMgr.Instance.HideView<GameStartView>();
  43. ViewMgr.Instance.HideView<ChallengeOptionView>();
  44. ViewMgr.Instance.HideView<RoleSelectView>();
  45. ViewMgr.Instance.HideView<PKGameOptionView>();
  46. ViewMgr.Instance.HideView<PKMatchView>();
  47. }
  48. }