HomeMgr.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. if (CommonConfig.StandaloneMode)
  36. {
  37. DoTweenUtil.CallDelay(0.1f, () => new UserPlayer());
  38. }
  39. else UserPlayer.ConnectServer();
  40. }
  41. void OnDestroy()
  42. {
  43. if (ins == this) ins = null;
  44. ViewMgr.Instance.DestroyAllViewsExcludeDontDestroy();
  45. //隐藏可缓存的页面
  46. ViewMgr.Instance.HideView<GameStartView>();
  47. ViewMgr.Instance.HideView<ChallengeOptionView>();
  48. ViewMgr.Instance.HideView<RoleSelectView>();
  49. ViewMgr.Instance.HideView<PKGameOptionView>();
  50. ViewMgr.Instance.HideView<PKMatchView>();
  51. }
  52. }