LoadDll.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Reflection;
  7. using System.Threading.Tasks;
  8. using UnityEngine;
  9. using UnityEngine.Networking;
  10. public class LoadDll : MonoBehaviour
  11. {
  12. void Start()
  13. {
  14. StartCoroutine(SendHttp("https://wx-model-1317557471.cos.ap-shanghai.myqcloud.com/HotUpdate.dll.bytes"));
  15. }
  16. public IEnumerator SendHttp(string url)
  17. {
  18. Debug.Log("HybridCLRStart1");
  19. UnityWebRequest webRequest = UnityWebRequest.Get(url);
  20. webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
  21. yield return webRequest.SendWebRequest();
  22. if (webRequest.isDone)
  23. {
  24. Assembly hotUpdateAss = Assembly.Load(webRequest.downloadHandler.data);
  25. Debug.Log("HybridCLRStart2");
  26. Type type = hotUpdateAss.GetType("Hello");
  27. Debug.Log("HybridCLRStart3");
  28. type.GetMethod("Run").Invoke(null, null);
  29. Debug.Log("HybridCLRStart4");
  30. }
  31. }
  32. }