public IEnumerator Load(BundleLoadOperation op, int streamIndex, string path) { int bundleIndex = op.nextBundle; string bundleName = op.GetBundleName(bundleIndex); yield return(null); if (!File.Exists(Path.Combine(path, bundleName))) { op.BundleFailed(bundleIndex, streamIndex, GetErrorMsg(bundleName, path)); yield break; } AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(path + bundleName); while (!request.isDone) { Debug.Log("[TransportFromFile] progress: " + op.progress); op.SetCurrentBundleProgress(op.progress); if (request.assetBundle == null) { op.BundleFailed(bundleIndex, streamIndex, GetErrorMsg(bundleName, path)); yield break; } yield return(null); } op.BundleLoaded(bundleIndex, streamIndex, request.assetBundle); }
public IEnumerator Load(BundleLoadOperation op, int streamIndex, string path) { int bundleIndex = op.nextBundle; string bundleName = op.GetBundleName(bundleIndex); // Due to how fast some bundles load, make the transporter wait a frame // before starting the loading. This is important for the editor, where // loading is instantaneous. // Important to get the bundle first yield return(null); UnityWebRequest request = UnityWebRequest.GetAssetBundle(path + bundleName); // Cloud Build will throw an error for this line. // warning CS0618: `UnityEngine.Networking.UnityWebRequest.Send()' is obsolete: // `Use SendWebRequest. It returns a UnityWebRequestAsyncOperation which contains // a reference to the WebRequest object.' // For some reason, Rider won't accept SendWebRequest as a valid method. request.Send(); while (!request.isDone) { op.SetCurrentBundleProgress(request.downloadProgress); if (request.isHttpError || request.isNetworkError) { op.BundleFailed(bundleIndex, streamIndex, request.error); yield break; } yield return(null); } op.BundleLoaded(bundleIndex, streamIndex, DownloadHandlerAssetBundle.GetContent(request)); }
public AssetBundleLoadStatus LoadMasterManifest() { string bundleName = BundlesHelper.GetPlatformName(); loadHandlers.Add(bundleName, OnMasterManifestLoaded); BundleLoadOperation loadOp = AddLoadOp(bundleName); return(new AssetBundleLoadStatus(loadOp)); }
public AssetBundleLoadStatus LoadBundle(string bundleName) { List <string> bundleNames = new List <string>(); bundleNames.AddRange(manifest.GetAllDependencies(bundleName)); bundleNames.Add(bundleName); onLoadBundles(bundleNames); BundleLoadOperation loadOp = AddLoadOp(bundleNames); return(new AssetBundleLoadStatus(loadOp)); }
public void OnLoadOpFailed(BundleLoadOperation op) { Debug.Log("[ABM] OnLoadOpFailed"); Debug.Log("[ABM] error: " + op.error + " msg: " + op.errorMsg); loadOps.Despawn(op); if (loadOps.numSpawned > 0) { return; } Debug.Log("[ABM] All LoadOps complete"); updater.Deactivate(); loader.StopAllCoroutines(); streams.Clear(); }
public void OnLoadOpComplete(BundleLoadOperation op) { Debug.Log("[ABM] OnLoadOpComplete"); loadOps.Despawn(op); if (loadOps.numSpawned > 0) { return; } Debug.Log("[ABM] All LoadOps complete"); updater.Deactivate(); loader.StopAllCoroutines(); streams.Clear(); // Debug.Log("Cleared all streams: "+streams.Count); }
public void Update() { if (freeStreams == 0) { return; } for (int i = 0; i < loadOps.numSpawned; ++i) { BundleLoadOperation op = loadOps.GetInstance(i); // This prevents the manager from loading bundles from a single loadop in parallell // Should check number of bundles left to load. // A LoadOp is not necessarily done just because there are no mor bundles to load. //if (op.bundlesLeftToLoad == 0) { // continue; //} if (!op.canLoadBundle) { continue; } if (freeStreams == 0) { return; } // Debug.Log("LoadOp "+i+" has "+op.bundlesLeftToLoad+" bundles left to load"); // Debug.Log("LoadOp "+i+" is ready"); ITransporter transporter = BundlesHelper.GetTransporter(config); // Debug.Log("Got transporter "+transporter.GetType()); // Debug.Log("Start transporter on stream "+streams.Count); string path = BundlesHelper.GetPath(config, BundlesHelper.GetPlatformName()); streams.Add(loader.StartCoroutine(transporter.Load(op, streams.Count, path))); // Debug.Log("Streams: "+streams.Count); --freeStreams; // Debug.Log("Started loading stream. Streams: "+streams.Count+" free streams: "+freeStreams); } }
public AssetBundleLoadStatus(BundleLoadOperation loadOp) { op = loadOp; }