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. 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. #if UNITY_ANDROID&& !UNITY_EDITOR
  48. _gameZip = new GameZip();
  49. _gameZip.Start(_gameStartUIPanel, this, StartLoadGame);
  50. #else
  51. StartLoadGame();
  52. #endif
  53. }
  54. private void StartLoadGame()
  55. {
  56. string typeName = "GameApplction";
  57. // lock (ActivatorLoock)
  58. {
  59. Assembly assembly = Assembly.Load("Fort23.Mono");
  60. Debug.Log("assembly" + assembly);
  61. System.Type type = assembly.GetType(typeName);
  62. Debug.Log("assembly——type" + type);
  63. IGameStart iGameStart = System.Activator.CreateInstance(type) as IGameStart;
  64. iGameStart.StartGame(LoadType, h5Url, _gameStartUIPanel, delegate { gameObject.SetActive(false); });
  65. }
  66. }
  67. private void Update()
  68. {
  69. FileDownloadSystem.Instance.Update();
  70. }
  71. }