GameStart.cs 2.2 KB

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