HomeMgr.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using JCUnityLib;
  5. using UnityEngine.SceneManagement;
  6. /* Home场景管理者 */
  7. public class HomeMgr : MonoBehaviour
  8. {
  9. public static HomeMgr ins;
  10. void Awake()
  11. {
  12. ins = this;
  13. PersistenHandler.Init();
  14. //ViewMgr.Instance.ShowView<TopBarView>();
  15. ViewMgr.Instance.ShowView<HomeView>();
  16. //ViewMgr.Instance.ShowView<HomeFrameView>();
  17. Instantiate(SceneResourceManager.Instance.GetPrefab("DeviceBatteryView"));
  18. Instantiate(SceneResourceManager.Instance.GetPrefab("AuthLoginMask"));
  19. //Instantiate(SceneResourceManager.Instance.GetPrefab("RenderBowCamera"));
  20. Instantiate(SceneResourceManager.Instance.GetPrefab("NewUserGuiderManager"));
  21. //标记某些界面不需要销毁
  22. // ViewMgr.Instance.SetViewDontDestroy<GameStartView>();
  23. //ViewMgr.Instance.SetViewDontDestroy<ChallengeOptionView>();
  24. ViewMgr.Instance.SetViewDontDestroy<RoleSelectView>();
  25. //ViewMgr.Instance.SetViewDontDestroy<PKGameOptionView>();
  26. ViewMgr.Instance.SetViewDontDestroy<PKMatchView>();
  27. //显示缓存的隐藏页面
  28. //ViewMgr.Instance.ResumeView<GameStartView>();
  29. //ViewMgr.Instance.ResumeView<ChallengeOptionView>();
  30. ViewMgr.Instance.ResumeView<RoleSelectView>();
  31. //ViewMgr.Instance.ResumeView<PKGameOptionView>();
  32. ViewMgr.Instance.ResumeView<PKMatchView>();
  33. //红外界面
  34. InfraredDemo.Create();
  35. }
  36. void Start()
  37. {
  38. Time.timeScale = 1; //保证时间缩放为1
  39. //单机版本
  40. if (CommonConfig.StandaloneMode)
  41. {
  42. DoTweenUtil.CallDelay(0.1f, () => new UserPlayer());
  43. //带投币功能-b端
  44. if (CommonConfig.StandaloneModeOrPlatformB) StandaloneAPI.InitTimeCounter();
  45. }
  46. else UserPlayer.ConnectServer();
  47. }
  48. void OnDestroy()
  49. {
  50. if (ins == this) ins = null;
  51. ViewMgr.Instance.DestroyAllViewsExcludeDontDestroy();
  52. //隐藏可缓存的页面
  53. //ViewMgr.Instance.HideView<GameStartView>();
  54. //ViewMgr.Instance.HideView<ChallengeOptionView>();
  55. ViewMgr.Instance.HideView<RoleSelectView>();
  56. //ViewMgr.Instance.HideView<PKGameOptionView>();
  57. ViewMgr.Instance.HideView<PKMatchView>();
  58. }
  59. }