GameStart.cs 2.5 KB

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