public IEnumerator DownloadAssetBundles() { Screen.sleepTimeout = -1; Int32 curItem = 0; Int32 numItem = AssetManager.DictAssetBundleRefs.Count; foreach (KeyValuePair <String, AssetManager.AssetBundleRef> entry in AssetManager.DictAssetBundleRefs) { AssetManager.AssetBundleRef abRef = entry.Value; if (abRef.assetBundle != (UnityEngine.Object)null) { break; } yield return(base.StartCoroutine(this.DownloadAssetBundle(abRef, curItem, numItem))); curItem++; } this._SetStatusText("Load Completed"); ExpansionVerifier.printLog("BundleScene : Load Completed"); Screen.sleepTimeout = -2; this._OnDownloadFinished(); yield return(null); yield break; }
public IEnumerator DownloadAssetBundle(AssetManager.AssetBundleRef abRef, Int32 curItem, Int32 numItem) { while (!Caching.ready) { yield return(null); } this._AddLogOutput("Downloading : " + abRef.url); String fullUrl = String.Concat(new String[] { this._baseUrl, AssetManagerUtil.GetPlatformPrefix(Application.platform), AssetManagerUtil.GetCompressionPrefix(this._isCompressedBundles), abRef.url, AssetManagerUtil.GetBundleExtension() }); this._AddLogOutput(" At : " + fullUrl); ExpansionVerifier.printLog("BundleScene : Downloading " + abRef.url + " AT " + fullUrl); if (!this._isCompressedBundles && fullUrl.IndexOf("http://") == -1) { this._AddLogOutput("Loading Uncompressed Bundle."); AssetBundle ab = AssetBundle.CreateFromFile(fullUrl); abRef.assetBundle = ab; yield break; } using (WWW www = WWW.LoadFromCacheOrDownload(fullUrl, BundleScene.BundleVersionInt)) { this._AddLogOutput("Loading Compressed Bundle."); while (!www.isDone) { this._SetStatusText(String.Concat(new Object[] { "Loading Progress : [", Mathf.FloorToInt(www.progress * 100f), "%] ", curItem, "/", numItem, " | Will auto change scene when finished." })); yield return(new WaitForSeconds(0.01f)); } if (www.error != null) { this._AddLogOutput("Error : " + www.error); ExpansionVerifier.printLog("BundleScene : www.error = " + www.error); throw new Exception("WWW download:" + www.error); } abRef.assetBundle = www.assetBundle; } yield break; }
public static void ClearCache() { Caching.CleanCache(); foreach (KeyValuePair <String, AssetManager.AssetBundleRef> keyValuePair in AssetManager.DictAssetBundleRefs) { AssetManager.AssetBundleRef value = keyValuePair.Value; if (value.assetBundle != (UnityEngine.Object)null) { value.assetBundle.Unload(true); value.assetBundle = (AssetBundle)null; } } }
public IEnumerator DownloadAssetBundles() { Screen.sleepTimeout = -1; Int32 curItem = 0; Int32 numItem = AssetManager.DictAssetBundleRefs.Count; if (!BundleSceneIOS.Are3CompressedBundlesCached()) { global::Debug.Log("Need to check free space"); if (Storage.GetFreeSpace() < 382335908UL) { this.LoadingUI.SetSceneActive(true); this.LoadingUI.SetStatusText(ExpansionVerifier.State.DecompressFailure, ExpansionVerifier.ErrorCode.NotEnoughStorage); yield break; } AssetManager.ClearCache(); Single curTime = Time.realtimeSinceStartup; Single percent = 0f; while (Time.realtimeSinceStartup - curTime < 5f) { percent = (Time.realtimeSinceStartup - curTime) / 5f; this.LoadingUI.SetSceneActive(true); this.LoadingUI.SetStatusText(ExpansionVerifier.State.DecompressOBB, ExpansionVerifier.ErrorCode.None); Single total = ((Single)this.currentProgressIndex + percent) * 100f; Single totalProgress = total / 4f; this.LoadingUI.SetProgress(Mathf.FloorToInt(totalProgress), true); yield return(new WaitForSeconds(0.3f)); } this.currentProgressIndex++; } foreach (KeyValuePair <String, AssetManager.AssetBundleRef> entry in AssetManager.DictAssetBundleRefs) { AssetManager.AssetBundleRef abRef = entry.Value; if (abRef.assetBundle != (UnityEngine.Object)null) { break; } yield return(base.StartCoroutine(this.DownloadAssetBundle(abRef, curItem, numItem))); curItem++; } this._SetStatusText("Load Completed"); Screen.sleepTimeout = -2; this._OnDownloadFinished(); yield return(null); yield break; }
public static T Load <T>(String name, Boolean suppressError = false) where T : UnityEngine.Object { if (AssetManagerForObb.IsUseOBB) { return(AssetManagerForObb.Load <T>(name, suppressError)); } if (!AssetManager.UseBundles || AssetManagerUtil.IsEmbededAssets(name)) { return(Resources.Load <T>(name)); } String belongingBundleFilename = AssetManagerUtil.GetBelongingBundleFilename(name); Boolean flag = AssetManagerUtil.CheckModuleBundleFromName(AssetManagerUtil.ModuleBundle.CommonAssets, name); if (!String.IsNullOrEmpty(belongingBundleFilename) && AssetManager.DictAssetBundleRefs.ContainsKey(belongingBundleFilename)) { AssetManager.AssetBundleRef assetBundleRef = AssetManager.DictAssetBundleRefs[belongingBundleFilename]; if (assetBundleRef.assetBundle != (UnityEngine.Object)null) { String text = AssetManagerUtil.GetResourcesBasePath() + name; text += AssetManagerUtil.GetAssetExtension <T>(name); Boolean flag2 = name.IndexOf("atlas_a") != -1; T t = assetBundleRef.assetBundle.LoadAsset <T>(text); if (t != (UnityEngine.Object)null) { return(t); } if (Application.platform != RuntimePlatform.Android && flag2) { return((T)((Object)null)); } if (!flag && AssetManager.ForceUseBundles) { return((T)((Object)null)); } } } if (AssetManager.ForceUseBundles) { return((T)((Object)null)); } T t2 = Resources.Load <T>(name); if (t2 != (UnityEngine.Object)null) { return(t2); } return((T)((Object)null)); }
public static AssetManagerRequest LoadAsync <T>(String name) where T : UnityEngine.Object { if (AssetManagerForObb.IsUseOBB) { return(AssetManagerForObb.LoadAsync <T>(name)); } if (!AssetManager.UseBundles || AssetManagerUtil.IsEmbededAssets(name)) { ResourceRequest resourceRequest = Resources.LoadAsync <T>(name); if (resourceRequest != null) { return(new AssetManagerRequest(resourceRequest, (AssetBundleRequest)null)); } } String belongingBundleFilename = AssetManagerUtil.GetBelongingBundleFilename(name); Boolean flag = AssetManagerUtil.CheckModuleBundleFromName(AssetManagerUtil.ModuleBundle.CommonAssets, name); if (!String.IsNullOrEmpty(belongingBundleFilename) && AssetManager.DictAssetBundleRefs.ContainsKey(belongingBundleFilename)) { AssetManager.AssetBundleRef assetBundleRef = AssetManager.DictAssetBundleRefs[belongingBundleFilename]; if (assetBundleRef.assetBundle != (UnityEngine.Object)null) { String text = AssetManagerUtil.GetResourcesBasePath() + name; text += AssetManagerUtil.GetAssetExtension <T>(name); Boolean flag2 = name.IndexOf("atlas_a") != -1; AssetBundleRequest assetBundleRequest = assetBundleRef.assetBundle.LoadAssetAsync(text); if (assetBundleRequest != null) { return(new AssetManagerRequest((ResourceRequest)null, assetBundleRequest)); } if (!flag && AssetManager.ForceUseBundles) { if (Application.platform != RuntimePlatform.Android && flag2) { return((AssetManagerRequest)null); } return((AssetManagerRequest)null); } } } ResourceRequest resourceRequest2 = Resources.LoadAsync <T>(name); if (resourceRequest2 != null) { return(new AssetManagerRequest(resourceRequest2, (AssetBundleRequest)null)); } return((AssetManagerRequest)null); }
public IEnumerator DownloadAssetBundle(AssetManager.AssetBundleRef abRef, Int32 curItem, Int32 numItem) { while (!Caching.ready) { yield return(null); } this._AddLogOutput("Downloading : " + abRef.url); String fullUrl = String.Concat(new String[] { this._baseUrl, AssetManagerUtil.GetPlatformPrefix(Application.platform), AssetManagerUtil.GetCompressionPrefix(this._isCompressedBundles), abRef.url, AssetManagerUtil.GetBundleExtension() }); this._AddLogOutput(" At : " + fullUrl); String prefix = AssetManagerUtil.GetPlatformPrefix(Application.platform); Boolean isCompressedBundles = this._isCompressedBundles; Boolean specialCaseOccured = fullUrl.Contains(prefix + "0data2.bin") || fullUrl.Contains(prefix + "0data3.bin") || fullUrl.Contains(prefix + "0data4.bin"); if (specialCaseOccured) { isCompressedBundles = true; String baseUrl = String.Empty; baseUrl = BundleSceneIOS.GetBasedURLForLocalBundles(); fullUrl = String.Concat(new String[] { baseUrl, AssetManagerUtil.GetPlatformPrefix(Application.platform), AssetManagerUtil.GetCompressionPrefix(isCompressedBundles), abRef.url, AssetManagerUtil.GetBundleExtension() }); } if (!isCompressedBundles && fullUrl.IndexOf("http://") == -1) { this._AddLogOutput("Loading Uncompressed Bundle."); AssetBundle ab = AssetBundle.CreateFromFile(fullUrl); abRef.assetBundle = ab; yield break; } Boolean isVersionCached = false; if (specialCaseOccured && Caching.IsVersionCached(fullUrl, BundleScene.BundleVersionInt)) { this.LoadingUI.SetSceneActive(false); isVersionCached = true; } using (WWW www = WWW.LoadFromCacheOrDownload(fullUrl, BundleScene.BundleVersionInt)) { this._AddLogOutput("Loading Compressed Bundle."); while (!www.isDone) { if (!isVersionCached) { this.LoadingUI.SetSceneActive(true); this.LoadingUI.SetStatusText(ExpansionVerifier.State.DecompressOBB, ExpansionVerifier.ErrorCode.None); } Single total = ((Single)this.currentProgressIndex + www.progress) * 100f; Single totalProgress = total / 4f; this.LoadingUI.SetProgress(Mathf.FloorToInt(totalProgress), true); global::Debug.Log("totalProgress + " + totalProgress); yield return(new WaitForSeconds(0.01f)); } this.currentProgressIndex++; if (www.error != null) { this._AddLogOutput("Error : " + www.error); throw new Exception("WWW download:" + www.error); } abRef.assetBundle = www.assetBundle; } yield break; }