GameLauncher.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using UnityEngine;
  2. using GFGGame;
  3. using GFGGame.Launcher;
  4. using FairyGUI;
  5. using System;
  6. using System.Collections.Generic;
  7. using YooAsset;
  8. using UnityEngine.SceneManagement;
  9. public class GameLauncher : MonoBehaviour
  10. {
  11. public static GameLauncher Instance;
  12. /// <summary>
  13. /// ×ÊԴϵͳÔËÐÐģʽ
  14. /// </summary>
  15. public EPlayMode PlayMode = EPlayMode.EditorSimulateMode;
  16. private void Awake()
  17. {
  18. Instance = this;
  19. DontDestroyOnLoad(gameObject);
  20. var roots = this.gameObject.scene.GetRootGameObjects();
  21. foreach(var t in roots)
  22. {
  23. if(t.name == "FairyGUI" || t.name == "Stage Camera")
  24. {
  25. DontDestroyOnLoad(t);
  26. }
  27. }
  28. }
  29. // Start is called before the first frame update
  30. void Start()
  31. {
  32. Screen.sleepTimeout = SleepTimeout.NeverSleep;
  33. Application.runInBackground = true;
  34. LauncherConfig.InitScriptCompilation();
  35. FGUILauncher.Init();
  36. HealthAdviceView.Open();
  37. int time = LauncherConfig.netType == LauncherConfig.EnumNetType.TISHEN ? 10 : 1;
  38. Timers.inst.Add(time, 1, (object param) =>
  39. {
  40. HealthAdviceView.Close();
  41. LauncherView.Instance.Open();
  42. LauncherController.InitLauncherCfg();
  43. });
  44. }
  45. }