private IEnumerator LoadAssetBundleByRecursive(string abName) { if (relationContainer == null) { yield break; } if (!relationContainer.ContainsKey(abName)) { relationContainer.Add(abName, new ABRelation(abName)); } var relation = relationContainer[abName]; var dependencies = ABManifestLoader.GetInstance().GetAllDependencies(abName); foreach (var item in dependencies) { relation.AddDependence(item); yield return(LoadReferenceByRecursive(item, abName)); } if (loaderContainer == null) { yield break; } if (!loaderContainer.ContainsKey(abName)) { loaderContainer.Add(abName, ABLoaderManager.Create(abName, manifest.GetAssetBundleHash(abName))); } yield return(loaderContainer[abName].LoadAssetBundle()); }
public IEnumerator DownloadAssetBundle() { yield return(WaitUntilMainifestLoad()); foreach (var abName in ABManifestLoader.GetInstance().AssetBundleList) { var sceneName = abName.Substring(0, abName.IndexOf("/")); StartCoroutine(LoadAssetBundle(sceneName, abName)); } while (ABLoaderManager.GetDownloadProgress() < 1) { yield return(null); } Resources.UnloadUnusedAssets(); System.GC.Collect(); }
public void Dispose() { try { foreach (var abName in loaderContainer.Keys) { ABLoaderManager.Dispose(abName); } } finally { loaderContainer.Clear(); loaderContainer = null; relationContainer.Clear(); relationContainer = null; onLoadCompleted = null; Resources.UnloadUnusedAssets(); System.GC.Collect(); } }