private void OfflineGameHandler(EventObj eo) { Debug.Log("Offline mode: ver " + eo.paramInt); if (eo.paramInt > 0) { savedupdateInfo = new AssetBundleUpdateInfo(eo.paramInt, eo.paramString); StartCoroutine(DownLoadManifestAndInitAssetBundleManager(savedupdateInfo)); } else { EventManager.TriggerEvent(new EventObj("AssetBundlesDownloaded")); } }
public static IEnumerator DownloadManifest(AssetBundleUpdateInfo updateInfo, bool bAutoDownloadAllAssetBundles = false) { #if UNITY_EDITOR // If we're in Editor simulation mode, we don't need the manifest assetBundle. if (AssetBundleManager.SimulateAssetBundleInEditor) { yield break; } #endif //beginning of patch downloading while (!Caching.ready) { yield return(null); } bIsDownloading = true; count = 0; while (DownloadedAssetBundleManifestObject == null) { count++; using (WWW www = WWW.LoadFromCacheOrDownload(updateInfo.url + Utility.GetPlatformName() + "/" + Utility.GetPlatformName(), updateInfo.ver)) { yield return(www); if (www.error == null) { DownloadedAssetBundleManifestObject = www.assetBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); www.Dispose(); break; } else if (DownloadedAssetBundleManifestObject == null && count == 6) { EventManager.TriggerEvent(new EventObj("Error", (int)ErrorCodeEnum.UpdateGame_Client_CantDownloadData)); count = 0; } www.Dispose(); yield return(new WaitForSeconds(1)); } } //ready to use the asset bundle manager AssetBundleManager.SetSourceAssetBundleURL(updateInfo.url); AssetBundleManager.InitializeWithManifest(DownloadedAssetBundleManifestObject, new string[2] { "hd", "sd" }); bIsDownloading = false; }
private IEnumerator DownLoadManifestAndInitAssetBundleManager(AssetBundleUpdateInfo updateInfo) { yield return(StartCoroutine(AssetsLoader.DownloadManifest(updateInfo))); #if UNITY_EDITOR // If we're in Editor simulation mode, we don't need the manifest assetBundle. if (!AssetBundleManager.SimulateAssetBundleInEditor) #endif { if (AssetBundleManager.AssetBundleManifestObject != null) { yield return(StartCoroutine(AssetsLoader.Instance.DownLoadAllAssetBundlesAsync())); } else { GlobalBehaviors.Instance.AddAMessageBox("Error", "You can't load game content index correctly :( Please try restart the game!", MessageBoxType.YES, "OK", null, null, null, null, null); //no way ... yield break; } } //load assets table first AssetsTableScriptableObject assetsTableObj; AssetsTableScriptableObject.AssetEntry assetsTableEntry = new AssetsTableScriptableObject.AssetEntry();//fake entry :D assetsTableEntry.AssetBundleName = "assetstable"; assetsTableEntry.AssetName = "assetsTable"; yield return(StartCoroutine(AssetsLoader.Instance.InstantiateObjectAsync(assetsTableEntry, (newAssetstable) => { if (newAssetstable != null) { assetsTableObj = newAssetstable as AssetsTableScriptableObject; if (assetsTableObj != null) { AssetsLoader.Instance.SetDownloadedAssetsTableObj(assetsTableObj); } } }))); EventManager.TriggerEvent(new EventObj("AssetBundlesDownloaded")); }
public void UpdateGame(string error, AssetBundleUpdateInfo updateInfo) { EventManager.RegisterEvent("AssetBundlesDownloaded", GameUpdated, true); if (string.IsNullOrEmpty(error)) { EventManager.TriggerEvent(new EventObj("UpdateGame", updateInfo.url, updateInfo.ver)); } else { GlobalBehaviors.Instance.AddAMessageBox("Opps~", "You can't reach the server right now :/ do you want to retry?", MessageBoxType.YESNO, "Retry", "Offline", null, () => { RequestUpdateGame(); }, () => { //todo read saved last time updateInfo can be an empty manifest application floder //save current gameplay as Offline Mode EventManager.TriggerEvent(new EventObj("OfflineGame", "your saved url", 1)); }, null); } }
private void UpdateGameHandler(EventObj eo) { savedupdateInfo = new AssetBundleUpdateInfo(eo.paramInt, eo.paramString); StartCoroutine(DownLoadManifestAndInitAssetBundleManager(savedupdateInfo)); }