public override void Start() { base.Start(); if (m_UnityWebRequest != null) { m_UnityWebRequest.Dispose(); m_UnityWebRequest = null; } bool isCache = false; string path = ResourceManager.instance.GetResourcePath(this.path, ref isCache, async); if (async) { string pathDst = FileUtil.GetAssetBundleFullPath(path); m_UnityWebRequest = UnityWebRequestAssetBundle.GetAssetBundle(pathDst, FileUtil.DefaultHash); } else { if (isCache) { AssetBundle assetbundle = AssetBundle.LoadFromFile(path); OnComplete(assetbundle); } else { // FGUI有bug.造成LoginPanel适配有问题.临时处理,先去掉UI的缓存 string pathDst = path; if (!path.StartsWith("ui/")) { string filename = System.IO.Path.GetFileNameWithoutExtension(path); pathDst = FileUtil.GetCacheAssetBundlePath(filename); if (!File.Exists(pathDst)) { // 不存在,读取源文本 pathDst = path; // 加到后台解压 path = FileUtil.GetAssetBundleFullPath(path); ResourceManager.instance.AddToDownloadOrCache(path); } } AssetBundle assetbundle = AssetBundle.LoadFromFile(pathDst); OnComplete(assetbundle); } } }
internal UnityWebRequest CreateWebRequest(string url) { if (m_Options == null) { return(UnityWebRequestAssetBundle.GetAssetBundle(url)); } UnityWebRequest webRequest; if (!string.IsNullOrEmpty(m_Options.Hash)) { CachedAssetBundle cachedBundle = new CachedAssetBundle(m_Options.BundleName, Hash128.Parse(m_Options.Hash)); #if ENABLE_CACHING if (m_Options.UseCrcForCachedBundle || !Caching.IsVersionCached(cachedBundle)) { webRequest = UnityWebRequestAssetBundle.GetAssetBundle(url, cachedBundle, m_Options.Crc); } else { webRequest = UnityWebRequestAssetBundle.GetAssetBundle(url, cachedBundle); } #else webRequest = UnityWebRequestAssetBundle.GetAssetBundle(url, cachedBundle, m_Options.Crc); #endif } else { webRequest = UnityWebRequestAssetBundle.GetAssetBundle(url, m_Options.Crc); } if (m_Options.Timeout > 0) { webRequest.timeout = m_Options.Timeout; } if (m_Options.RedirectLimit > 0) { webRequest.redirectLimit = m_Options.RedirectLimit; } #if !UNITY_2019_3_OR_NEWER webRequest.chunkedTransfer = m_Options.ChunkedTransfer; #endif if (m_ProvideHandle.ResourceManager.CertificateHandlerInstance != null) { webRequest.certificateHandler = m_ProvideHandle.ResourceManager.CertificateHandlerInstance; webRequest.disposeCertificateHandlerOnDispose = false; } m_ProvideHandle.ResourceManager.WebRequestOverride?.Invoke(webRequest); return(webRequest); }
// it must wait for the web call to occur IEnumerator Start() { var unityWebRequestAB = UnityWebRequestAssetBundle.GetAssetBundle(fallbackAssetBundleurl); //use yield as it can take sometime for the web request to occur depending on the internet connection - wait for that to happen yield return(unityWebRequestAB.SendWebRequest()); AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(unityWebRequestAB); var loadAsset = bundle.LoadAssetAsync(prefabName); //make asset load in sync with start so the program is not stuck during waiting if it's got other things to do yield return(loadAsset); Instantiate(loadAsset.asset); }
IEnumerator LoadDefaultSabers() { var path = Path.Combine(Application.streamingAssetsPath, "sabers_default"); #if UNITY_ANDROID var uwr = UnityWebRequestAssetBundle.GetAssetBundle(path); yield return(uwr.SendWebRequest()); var bundle = DownloadHandlerAssetBundle.GetContent(uwr); TryLoadSaberBundle(bundle); #else TryLoadSaberBundle(AssetBundle.LoadFromFile(path)); yield return(null); #endif }
//UnityWebRequest加载方式 IEnumerator InstantiateObject() { string url = "file:///" + Application.streamingAssetsPath + "/cube.unity3d"; UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(url);; yield return(request.SendWebRequest()); AssetBundle ab = DownloadHandlerAssetBundle.GetContent(request); if (ab != null) { GameObject cube = ab.LoadAsset <GameObject>("Cube"); Instantiate(cube); } }
IEnumerator InstantiateObject() { string url = "file:///" + Application.dataPath + "/AssetBundles/testassetbundle"; UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(url, 0); yield return(request.SendWebRequest()); AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request); GameObject cube = bundle.LoadAsset <GameObject>("Cube"); Instantiate(cube); GameObject sprite = bundle.LoadAsset <GameObject>("Sprite"); Instantiate(sprite); }
/// <summary> /// 加载依赖清单 /// </summary> /// <returns></returns> public IEnumerator ManifestLoad() { UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(_loadPath); yield return(request.SendWebRequest()); _manifestBundle = (request.downloadHandler as DownloadHandlerAssetBundle).assetBundle; if (_manifestBundle == null) { Debug.LogError(GetType() + "读取manifest失败:" + _loadPath); yield return(null); } _manifest = _manifestBundle.LoadAsset(AssetBundleDefined.ASSETBUNDLE_MANIFEST_STR) as AssetBundleManifest; _isLoadFinish = true; }
private void Update() { if (Input.GetKeyDown(KeyCode.Space)) { destoryModel(); Debug.Log("重新加载"); //重新加载 loadingBarSlider.gameObject.SetActive(true); //WWW www = new WWW(url); //addCoroutineList(StartCoroutine(showProgressAndLoadModel(www, scale))); StartCoroutine(showProgressAndLoadModel(UnityWebRequestAssetBundle.GetAssetBundle(url), Vector3.one)); //WWW www1 = new WWW(url); //addCoroutineList(StartCoroutine(showProgressAndLoadModel1(www1, scale))); } }
public IEnumerator DownloadAssetBundle(string url, downloadAssetBundleCallback cbk) { Debug.Log("下载AssetBundle: " + url); var uwr = UnityWebRequestAssetBundle.GetAssetBundle(url); yield return(uwr.SendWebRequest()); // Get an asset from the bundle. AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr); yield return(bundle); Debug.Log("下载完成."); cbk(bundle); }
public IEnumerator DownloadAssetBundle(string bundleUrl) { UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(bundleUrl); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { //bundle is cached } }
private IEnumerator Start() { //AssetBundle ab = AssetBundle.LoadFromFile("AssetBundles/wall.ab"); string uri = @"http://localhost/AssetBundles/cubewall.unity3d"; UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(uri); yield return(request.SendWebRequest()); AssetBundle ab = DownloadHandlerAssetBundle.GetContent(request); GameObject wallPrefab = ab.LoadAsset <GameObject>("CubeWall"); Instantiate(wallPrefab); }
//coroutine to get assetbundle from webserver IEnumerator GetAssetBundle() { //web request to get assetbundle from webserver, skips crc webRequest = UnityWebRequestAssetBundle.GetAssetBundle(assetBundleServerURL, 0); Debug.Log(webRequest == null ? "No web request" : "Web request exists"); yield return(webRequest.SendWebRequest()); //loads asset bundle ab = DownloadHandlerAssetBundle.GetContent(webRequest); Debug.Log(ab == null ? "Failed to load AssetBundle" : "Successfully Loaded AssetBundle"); //instantiate object from assetbundle GameObject monkey = ab.LoadAsset <GameObject>("monkey_lp"); Instantiate(monkey); }
IEnumerator DownloadAssets(string assetName, Vector3 pos) { DateTime start = DateTime.UtcNow; string url = "http://vcm-12481.vm.duke.edu/static/" + assetName; UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(url, 0); yield return(request.SendWebRequest()); AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request); TimeSpan timeDiff = DateTime.UtcNow - start; Debug.Log("Downloading" + assetName + "takes" + Convert.ToInt32(timeDiff.TotalMilliseconds)); _assetBundles.Add(new Tuple <string, Vector3, AssetBundle>(assetName, pos, bundle)); }
/// <summary> /// Loads the asset bundle asynchronously, returns the loaded object. /// </summary> public async Task <UnityEngine.AssetBundle> LoadAsync() { await _locker.LockAsync(async() => { if (UnityAssetBundle != null) { return; } Debug.Log("#Delight# Loading asset bundle: " + Id); // get bundle URI var bundleBaseUri = StorageMode == StorageMode.Remote ? Config.ServerUriLocator.GetServerUri(Id) : Application.streamingAssetsPath; if (!bundleBaseUri.EndsWith("/")) { bundleBaseUri += "/"; } var bundleUri = string.Empty; if (StorageMode == StorageMode.Remote) { bundleUri = String.Format("{0}{1}{2}{3}", bundleBaseUri, AssetBundleData.GetPlatformName() + "/", DelightAssetsFolder, Id.ToLower()); } else { bundleUri = String.Format("{0}{1}{2}", bundleBaseUri, DelightAssetsFolder, Id.ToLower()); } // get asset bundle var version = Version > 0 ? Version : Config.AssetBundleVersion; var getBundleRequest = version > 0 ? UnityWebRequestAssetBundle.GetAssetBundle(bundleUri, version, 0) : UnityWebRequestAssetBundle.GetAssetBundle(bundleUri); var response = (await getBundleRequest.SendWebRequest()) as UnityWebRequestAsyncOperation; if (response.webRequest.isNetworkError || response.webRequest.isHttpError) { Debug.Log(String.Format("#Delight# Failed to load asset bundle \"{0}\" from URI \"{1}\".", Id, bundleUri)); return; } // simulate slow load // await Task.Delay(1500); // TODO remove UnityAssetBundle = DownloadHandlerAssetBundle.GetContent(response.webRequest); }); return(UnityAssetBundle); }
public override IObservable <Unit> Download() { var bundleName = Path.GetFileNameWithoutExtension(Url); var hash = _manifest.GetAssetBundleHash(bundleName); _request = hash.isValid ? UnityWebRequestAssetBundle.GetAssetBundle(Url, hash, 0) : UnityWebRequestAssetBundle.GetAssetBundle(Url); _request.disposeDownloadHandlerOnDispose = true; return(_request.SendAsObserable() .ContinueWith(_ => { IsDownload = true; return Observable.ReturnUnit(); }).AsUnitObservable()); }
IEnumerator GetAssetBundle() { UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle("https://www.dropbox.com/s/la5pe2edt6m0x57/livenews?dl=1"); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www); scenePaths = bundle.GetAllScenePaths(); } }
/// <summary> /// Creates an asyncronous operation optimized for downloading a <see cref="AssetBundle"/> via HTTP GET. /// </summary> /// <param name="url">The URI of the asset bundle to download.</param> /// <param name="hash">A version hash. If this hash does not match the hash for the cached version of this asset bundle, the asset bundle will be redownloaded.</param> /// <returns>An operation that can be used to track the download process.</returns> public static IAsyncOperation <AssetBundle> GetAssetBundle(string url, Hash128 hash) { #if UNITY_2018_1_OR_NEWER var webRequest = UnityWebRequestAssetBundle.GetAssetBundle(url, hash, 0); var result = new Helpers.WebRequestResult <AssetBundle>(webRequest); #elif UNITY_5_4_OR_NEWER var webRequest = UnityWebRequest.GetAssetBundle(url, hash, 0); var result = new Helpers.WebRequestResult <AssetBundle>(webRequest); #else var www = WWW.LoadFromCacheOrDownload(url, hash); var result = new Helpers.WwwResult <AssetBundle>(www); #endif result.Start(); return(result); }
private IEnumerator LoadBundleRoutine(CachedAssetBundle cacheInfo, bool shouldBeCached) { var isCached = Caching.IsVersionCached(cacheInfo); Debug.Assert( isCached == shouldBeCached, $"Bundle was not cached when it should have been, should be cached: {shouldBeCached}, is cached: {isCached}"); using (var request = UnityWebRequestAssetBundle.GetAssetBundle(_bundleUrl, cacheInfo)) { yield return(request.SendWebRequest()); var bundle = DownloadHandlerAssetBundle.GetContent(request); bundle.Unload(true); } }
/// <summary> /// Creates an asyncronous operation optimized for downloading a <see cref="AssetBundle"/> via HTTP GET. /// </summary> /// <param name="url">The URI of the asset bundle to download.</param> /// <returns>An operation that can be used to track the download process.</returns> public static IAsyncOperation <AssetBundle> GetAssetBundle(string url) { #if UNITY_2018_1_OR_NEWER var webRequest = UnityWebRequestAssetBundle.GetAssetBundle(url); var result = new Helpers.WebRequestResult <AssetBundle>(webRequest); #elif UNITY_5_4_OR_NEWER var webRequest = UnityWebRequest.GetAssetBundle(url); var result = new Helpers.WebRequestResult <AssetBundle>(webRequest); #else var www = new WWW(url); var result = new Helpers.WwwResult <AssetBundle>(www); #endif result.Start(); return(result); }
IEnumerator DownloadAndCache() { string BundleUrl = "http://cfile218.uf.daum.net/attach/996F55355CDA60D61C0ED0"; //"file://" + Application.dataPath + "/AssetBundles/studyab";~~~~~로컬 //"http://cfile218.uf.daum.net/attach/996F55355CDA60D61C0ED0";~~~~서버 //서버에 올릴수 없는경우 ("file://"+로컬파일 경로)를 URL에 넣어줌 var request = UnityWebRequestAssetBundle.GetAssetBundle(BundleUrl);//UnityWebRequest.Get(BundleUrl); yield return(request.SendWebRequest()); AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request); GameObject sphere = bundle.LoadAsset <GameObject>("AB_Sphere"); Instantiate(sphere); }
/// <summary> /// オンラインプロセス開始イベント /// </summary> /// <returns>コルーチン</returns> protected override System.Collections.IEnumerator OnStartedOnlineProcess() { m_ErrorCode = AssetBundleErrorCode.Null; var fileNameAndURL = manager.GetAssetBundleFileNameAndURL(nameWithVariant); m_DownloadWork = new DownloadWork { url = fileNameAndURL.url, hash = manager.catalog.GetAssetBundleHash(nameWithVariant), crc = manager.catalog.GetAssetBundleCrc(nameWithVariant) }; #if UNITY_2018_1_OR_NEWER m_DownloadWork.request = UnityWebRequestAssetBundle.GetAssetBundle(m_DownloadWork.url, m_DownloadWork.hash, m_DownloadWork.crc); #else m_DownloadWork.request = UnityWebRequest.GetAssetBundle(m_DownloadWork.url, m_DownloadWork.hash, m_DownloadWork.crc); #endif var sendWebRequest = m_DownloadWork.request.SendWebRequest(); var progress = -1.0f; var startTime = Time.realtimeSinceStartup; while (!sendWebRequest.isDone) { yield return(null); if (progress != sendWebRequest.progress) { //進行 progress = sendWebRequest.progress; startTime = Time.realtimeSinceStartup; } else if (manager.downloadTimeoutSeconds < (Time.realtimeSinceStartup - startTime)) { //タイムアウト時間の停滞 break; } } if (m_DownloadWork.request.isNetworkError || m_DownloadWork.request.isHttpError) { AssetBundleErrorCodeUtility.TryParse(m_DownloadWork.request, out m_ErrorCode); } else { Caching.ClearOtherCachedVersions(fileNameAndURL.fileName, m_DownloadWork.hash); } yield return(base.OnStartedOnlineProcess()); }
IEnumerator DownloadAndCache() { // cache 폴더에 AssetBundle을 담을 것이므로 캐싱시스템이 준비 될 때까지 기다림 while (!Caching.ready) { yield return(null); } // 에셋번들을 캐시에 있으면 로드하고, 없으면 다운로드하여 캐시폴더에 저장합니다. using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(FarmBundleWinBundleURI)) { yield return(uwr.SendWebRequest()); if (uwr.isNetworkError || uwr.isHttpError) { Debug.LogError(uwr.error); } else { // Get downloaded asset bundle _farmAssetBundle = DownloadHandlerAssetBundle.GetContent(uwr); _farmLoadComplete = true; } } // using문은 File 및 Font 처럼 컴퓨터 에서 관리되는 리소스들을 쓰고 나서 쉽게 자원을 되돌려줄수 있도록 기능을 제공 using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(CharEquipWinBundleURI)) { yield return(uwr.SendWebRequest()); if (uwr.isNetworkError || uwr.isHttpError) { Debug.LogError(uwr.error); } else { // Get downloaded asset bundle _charEquipBundle = DownloadHandlerAssetBundle.GetContent(uwr); _charEquipLoadComplete = true; } } if (_farmLoadComplete && _charEquipLoadComplete) { IsLoadComplete = true; } }
public IEnumerator Load(string url) { Debug.LogFormat("BundleLoader.Load: {0}", url); switch (bundleLocation) { case BundleLocation.Local: GameObject go = Resources.Load(url) as GameObject; OnLoadComplete(go); break; case BundleLocation.Remote: using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(url)) { AsyncOperation request = uwr.SendWebRequest(); while (!request.isDone) { OnLoadProgress(request.progress); yield return(null); } if (uwr.isNetworkError || uwr.isHttpError) { OnLoadError(uwr.error); } else { AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr); // load asynchronously AssetBundleRequest abr = bundle.LoadAllAssetsAsync <GameObject>(); yield return(abr); bundle.Unload(false); uwr.Dispose(); GameObject obj = (GameObject)abr.asset; OnLoadComplete(obj); } } break; } yield return(null); }
// Update is called once per frame IEnumerator GetBundle() { loading = true; UnityMessageManager.Instance.SendMessageToRN("http://d3u3zwu9bmcdht.cloudfront.net/" + MessageURL.url); UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle("http://d3u3zwu9bmcdht.cloudfront.net/" + MessageURL.url); // www.downloadHandler = new DownloadHandlerBuffer(); yield return(www.SendWebRequest()); Debug.Log("http://d3u3zwu9bmcdht.cloudfront.net/" + MessageURL.url); if (www.result != UnityWebRequest.Result.Success) { // UnityMessageManager.Instance.SendMessageToRN(www); Debug.Log(www.error); } else { AssetBundle assetFile = DownloadHandlerAssetBundle.GetContent(www); if (assetFile == null) { UnityMessageManager.Instance.SendMessageToRN("Asset Load Error"); Debug.Log("Asset Load Error"); } AssetBundleRequest prefab = assetFile.LoadAssetAsync(MessageURL.name); yield return(prefab); assetFile.Unload(false); www.Dispose(); modelObject = prefab.asset as GameObject; } /**** init for .dae file ****/ // if (daeObject != null) // Destroy(daeObject.transform.GetChild(0).gameObject); daeObject = Instantiate(modelObject); // 태그 설정을 위해선 해당 태그 이름을 먼저 만들어 줘야한다. // 만약 동적인 tag가 필요하다면 editor script가 필요하다. daeObject.transform.tag = "Model"; // destroy camera object in .dae daeObject.AddComponent <sizeInit>(); }
private IEnumerator MakeDownloadCall(string target) { string requestUrl = APIDomain + target; UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(requestUrl); UnityWebRequestAsyncOperation operation = www.SendWebRequest(); Console.Log("Downloading " + requestUrl); while (!operation.isDone) { if (downloadProgress != null) { downloadProgress(www.downloadProgress * 100f); } yield return(null); } if (www.isNetworkError || www.isHttpError) { Console.Log("Communication error: " + www.error); if (downloadFinish != null) { downloadFinish(null); } if (downloadFailure != null) { downloadFailure(null); } } else { Console.Log("Download completed."); AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www); if (downloadProgress != null) { downloadProgress(www.downloadProgress * 100f); } if (downloadFinish != null) { downloadFinish(bundle); } if (downloadSuccess != null) { downloadSuccess(bundle); } } }
public Text progressText;//进度显示 IEnumerator GetAssetBundle(Action callBack) { UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(path); www.SendWebRequest(); while (!www.isDone) { Debug.Log(www.downloadProgress); slider.value = www.downloadProgress;//下载进度 progressText.text = Math.Floor(www.downloadProgress * 100) + "%"; yield return(1); } // 下载完成 if (www.isDone) { progressText.text = 100 + "%"; slider.value = 1; // 隐藏UI(等待1s) yield return(new WaitForSeconds(1)); GameObject.Find("Canvas").SetActive(false); } if (www.isNetworkError || www.isHttpError) { Debug.Log("DownLoad Err: " + www.error); } else { assetBundle = DownloadHandlerAssetBundle.GetContent(www); TextAsset hot = assetBundle.LoadAsset <TextAsset>("luaScript.lua.txt"); string newPath = Application.persistentDataPath + @"/luaScript.lua.txt"; if (!File.Exists(newPath)) { // Create后如果不主动释放资源就会被占用,下次打开会报错,所以一定要加上 .Dispose() File.Create(newPath).Dispose(); } // 写入文件 File.WriteAllText(newPath, hot.text); Debug.Log("下载资源成功!new Path : " + newPath); // 下载成功后 读取执行lua脚本 callBack(); } }
private IEnumerator DownloadAssetBundle(TileChange tileChange, System.Action <TileChange> callback = null) { int lod = tiles[new Vector2Int(tileChange.X, tileChange.Y)].LOD; string url = Config.activeConfiguration.webserverRootPath + Datasets[lod].path; if (Datasets[lod].path.StartsWith("https://")) { url = Datasets[lod].path; } url = url.Replace("{x}", tileChange.X.ToString()); url = url.Replace("{y}", tileChange.Y.ToString()); using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(url)) { yield return(uwr.SendWebRequest()); if (uwr.isNetworkError || uwr.isHttpError) { RemoveGameObjectFromTile(tileChange); callback(tileChange); } else { AssetBundle assetBundle = DownloadHandlerAssetBundle.GetContent(uwr); yield return(new WaitUntil(() => pauseLoading == false)); GameObject newGameobject = CreateNewGameObject(assetBundle, tileChange); if (newGameobject != null) { if (TileHasHighlight(tileChange)) { StartCoroutine(DownloadIDMappingData(tileChange, newGameobject, callback)); } else { RemoveGameObjectFromTile(tileChange); tiles[new Vector2Int(tileChange.X, tileChange.Y)].gameObject = newGameobject; callback(tileChange); } } else { callback(tileChange); } } } }
public override void Start() { base.Start(); if (async) { string fullPath = this.path; bool hasHead = (bool)param; if (!hasHead) { bool addFileHead = true; #if UNITY_ANDROID && !UNITY_EDITOR // 如果是读取apk里的资源,不需要加file:///,其它情况都要加 if (path.Contains(Application.streamingAssetsPath)) { addFileHead = false; } #endif // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (addFileHead) { fullPath = string.Format("file:///{0}", path); } } m_UnityWebRequest = UnityWebRequestAssetBundle.GetAssetBundle(fullPath); } else { object data = null; try { data = FileUtil.ReadByteFromFile(path); } catch (Exception e) { UnityEngine.Debug.LogError(e.Message); } finally { OnComplete(data); } } }
IEnumerator load() { name = @"C:\Users\Administrator\Desktop\aa\" + neme + ".assetbundle"; UnityWebRequest unityWebRequest = UnityWebRequestAssetBundle.GetAssetBundle(name, 0); yield return(unityWebRequest.SendWebRequest()); AssetBundle asset = DownloadHandlerAssetBundle.GetContent(unityWebRequest); LoadAssetBundle(asset, transform); yield return(null); LoadJsonForTrigger(asset, transform); yield return(null); HandleJsonForTrigger(); }
IEnumerator GetAssetBundle(string bundleUrl) { using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(bundleUrl)) { yield return(uwr.SendWebRequest()); if (uwr.isNetworkError || uwr.isHttpError) { Debug.Log(uwr.error); } else { myLoadedAssetbundle = DownloadHandlerAssetBundle.GetContent(uwr); InstatiateObjectFromBundle(assetName); } } }