HomeMgr.cs 2.1 KB

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