public void Update() { if (loading) { //loading into memory process for (int i = loadingBundles.Count - 1; i > -1; i--) { Bundle bundle = loadingBundles[i]; if (bundle.www.isDone) { loadedBundles[bundle.name] = bundle; loadingBundles.RemoveAt(i); if (loadingScene) { bundle.sceneBundle = bundle.www.assetBundle; } } } loading = loadingBundles.Count > 0; if (!loading) { this.enabled = checkPending; if (this.loadingScene) { this.loadingScene = false; OnSceneLoaded callback = this.onSceneLoaded; this.onSceneLoaded = null; if (callback != null) { callback(); } } else { OnBundleLoaded callback = this.onBundleLoaded; this.onBundleLoaded = null; if (callback != null) { callback(); } } if (needNotifyPending) { notifyPending(); } } } else if (checkPending) { checkPending = false; loadPending(); } else { //downloading process if (pendingBundles == null) { return; } if (!downloading) { for (int i = pendingBundles.Count - 1; i > -1; i--) { Bundle bundle = pendingBundles[i]; if (bundle.completed) { pendingBundles.RemoveAt(i); completedCount++; } else if (!bundle.started) { currentBundle = bundle; currentBundle.started = true; downloading = true; StartCoroutine(downloadBundle(currentBundle)); break; } } } completed = pendingBundles.Count == 0; //notify progress listener if any if (progressListener != null) { //current single bundle download progress float currentBundleProgress = 0; if (currentBundle != null && currentBundle.www != null) { currentBundleProgress = currentBundle.www.progress; } else if (completed) { currentBundleProgress = 1f; totalCount = completedCount; } progressListener.onProgress(totalCount, completedCount, currentBundleProgress); if (completed) { IProgressListener listener = progressListener; progressListener = null; StartCoroutine(notifyCompleted(listener)); } } } }