protected IEnumerator GetBundleFromWebOrCacheOperation <T>(BundleRequest bundleNeeded, IObserver <T> observer, CancellationToken cancellationToken) where T : UnityEngine.Object { UnityWebRequest www = null; ManifestInfo manifestInfo = new ManifestInfo(bundleNeeded); AssetBundle bundle; Debug.Log(("AssetBundleLoader: " + bundleNeeded.AssetCacheState + " | Requesting: " + bundleNeeded.AssetName + " | " + bundleNeeded.BundleName).Colored(Colors.aqua)); if (bundleNeeded.AssetCacheState.Equals(bundleNeeded.AssetCacheState)) { yield return(manifestInfo.GetInfo().ToYieldInstruction()); www = UnityWebRequest.GetAssetBundle(bundleNeeded.AssetPath, manifestInfo.Hash, 0); } else { www = UnityWebRequest.GetAssetBundle(bundleNeeded.AssetPath); } yield return(www.SendWebRequest()); bundle = DownloadHandlerAssetBundle.GetContent(www); if (www.isNetworkError) { observer.OnError(new System.Exception("AssetBundleLoader: " + www.error)); } else { ProcessDownloadedBundle <T>(bundleNeeded, new LoadedBundle(bundle, manifestInfo)) .Subscribe(xs => { observer.OnNext(xs); observer.OnCompleted(); }); } www.Dispose(); }
public LoadedBundle(AssetBundle asset, ManifestInfo info) { assetBundle = asset; manifestInfo = info; }