GameStart.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Reflection;
  3. using UnityEngine;
  4. using UnityEngine.Playables;
  5. public class GameStart : MonoBehaviour
  6. {
  7. public ShaderVariantCollection ShaderVariantCollection;
  8. public LoadType LoadType;
  9. public string h5Url;
  10. private GameStartUIPanel _gameStartUIPanel;
  11. private GameZip _gameZip;
  12. [ContextMenu("asdada")]
  13. public void Test()
  14. {
  15. }
  16. public void Start()
  17. {
  18. float bl = (Screen.dpi / 160) - 1;
  19. float b = bl / 1.75f;
  20. if (b > 1)
  21. {
  22. b = 1;
  23. }
  24. if (b < 0)
  25. {
  26. b = 0;
  27. }
  28. float bili = Mathf.Lerp(1, 0.7f, b);
  29. Screen.SetResolution((int)(Screen.width * bili), (int)(Screen.height * bili), true);
  30. QualitySettings.vSyncCount = 0;
  31. Application.targetFrameRate = 60;
  32. PottingMobile.InitializeSdk();
  33. PottingMobile.withLogDebug(true);
  34. ShaderVariantCollection.WarmUp();
  35. _gameStartUIPanel = GetComponent<GameStartUIPanel>();
  36. #if UNITY_ANDROID&& !UNITY_EDITOR
  37. _gameZip = new GameZip();
  38. _gameZip.Start(_gameStartUIPanel, this, StartLoadGame);
  39. #else
  40. StartLoadGame();
  41. #endif
  42. }
  43. private void StartLoadGame()
  44. {
  45. string typeName = "GameApplction";
  46. // lock (ActivatorLoock)
  47. {
  48. Assembly assembly = Assembly.Load("Fort23.Mono");
  49. System.Type type = assembly.GetType(typeName);
  50. IGameStart iGameStart = System.Activator.CreateInstance(type) as IGameStart;
  51. iGameStart.StartGame(LoadType, h5Url, _gameStartUIPanel, delegate { gameObject.SetActive(false); });
  52. }
  53. }
  54. private void Update()
  55. {
  56. FileDownloadSystem.Instance.Update();
  57. }
  58. }