using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Threading.Tasks; using UnityEngine; using UnityEngine.Networking; public class LoadDll : MonoBehaviour { void Start() { StartCoroutine(SendHttp("https://wx-model-1317557471.cos.ap-shanghai.myqcloud.com/HotUpdate.dll.bytes")); } public IEnumerator SendHttp(string url) { Debug.Log("HybridCLRStart1"); UnityWebRequest webRequest = UnityWebRequest.Get(url); webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); yield return webRequest.SendWebRequest(); if (webRequest.isDone) { Assembly hotUpdateAss = Assembly.Load(webRequest.downloadHandler.data); Debug.Log("HybridCLRStart2"); Type type = hotUpdateAss.GetType("Hello"); Debug.Log("HybridCLRStart3"); type.GetMethod("Run").Invoke(null, null); Debug.Log("HybridCLRStart4"); StartCoroutine(LoadAB("https://wx-model-1317557471.cos.ap-shanghai.myqcloud.com/canvas")); StartCoroutine(LoadAB("https://wx-model-1317557471.cos.ap-shanghai.myqcloud.com/cube")); } } // Start is called before the first frame update IEnumerator LoadAB(string url) { Debug.Log("LoadAB"); UnityWebRequest webRequest = UnityWebRequest.Get(url); webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); yield return webRequest.SendWebRequest(); if (webRequest.isDone) { AssetBundleCreateRequest request = AssetBundle.LoadFromMemoryAsync(webRequest.downloadHandler.data); yield return request;//µÈ´ýÏìÓ¦ AssetBundle ab = request.assetBundle; GameObject[] objs = ab.LoadAllAssets(); Debug.Log("HybridCLRStart5"); foreach (var item in objs) { Instantiate(item); } } } }