HomeMgr.cs 2.2 KB

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