GameStart.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. ShaderVariantCollection.WarmUp();
  36. _gameStartUIPanel = GetComponent<GameStartUIPanel>();
  37. HotSyncContent.isOpenDllStreamingLoad = isLoadDll;
  38. HotSyncContent.isOpenHotFix = isOpenHotFix;
  39. GameLoadDll gameLoadDll = new GameLoadDll();
  40. gameLoadDll.StartLoadDll(_gameStartUIPanel, this, "http://129.204.254.216:8080/resource/010test/init.dll",
  41. DllLoadFinish);
  42. }
  43. private void DllLoadFinish()
  44. {
  45. // StartLoadGame();
  46. #if UNITY_ANDROID&& !UNITY_EDITOR
  47. _gameZip = new GameZip();
  48. _gameZip.Start(_gameStartUIPanel, this, StartLoadGame);
  49. #else
  50. StartLoadGame();
  51. #endif
  52. }
  53. private void StartLoadGame()
  54. {
  55. string typeName = "GameApplction";
  56. // lock (ActivatorLoock)
  57. {
  58. Assembly assembly = Assembly.Load("Fort23.Mono");
  59. Debug.Log("assembly" + assembly);
  60. System.Type type = assembly.GetType(typeName);
  61. Debug.Log("assembly——type" + type);
  62. IGameStart iGameStart = System.Activator.CreateInstance(type) as IGameStart;
  63. iGameStart.StartGame(LoadType, h5Url, _gameStartUIPanel, delegate { gameObject.SetActive(false); });
  64. }
  65. }
  66. private void Update()
  67. {
  68. FileDownloadSystem.Instance.Update();
  69. }
  70. }