/// <summary> /// アセットバンドル情報一覧のファイル保存 /// </summary> /// <param name="outputPath">出力先のパス</param> /// <param name="assetBundleManifest">ビルドしたアセットバンドルの全体マニフェスト</param> private static void SaveAssetBundleInfoListFile(string outputPath, AssetBundleManifest assetBundleManifest) { var builtAssetBundleNames = assetBundleManifest.GetAllAssetBundles(); var assetBundleInfoList = new AssetBundleInfoList(); assetBundleInfoList.AssetBundleInfos = new List <AssetBundleInfo>(); for (var i = 0; i < builtAssetBundleNames.Length; ++i) { var assetBundlePath = string.Format("{0}/{1}", outputPath, builtAssetBundleNames[i]); var assetBundleInfo = new AssetBundleInfo(); assetBundleInfo.AssetBundleName = builtAssetBundleNames[i]; assetBundleInfo.DependenciesBundleNames = assetBundleManifest.GetAllDependencies(builtAssetBundleNames[i]); assetBundleInfo.HashString = assetBundleManifest.GetAssetBundleHash(builtAssetBundleNames[i]).ToString(); uint crc; if (BuildPipeline.GetCRCForAssetBundle(assetBundlePath, out crc)) { assetBundleInfo.Crc = crc; } assetBundleInfoList.AssetBundleInfos.Add(assetBundleInfo); } var jsonString = JsonUtility.ToJson(assetBundleInfoList); var fullPath = string.Format("{0}/{1}", outputPath, AssetBundleManagerConfig.AssetBundleInfoListFileName); System.IO.File.WriteAllText(fullPath, jsonString); }
/// <summary> /// アセットバンドル情報一覧のダウンロード /// </summary> /// <returns>コルーチン</returns> public IEnumerator DownloadAssetBundleInfoList() { var platformName = PlatformNameManager.GetPlatformName(Application.platform); var url = string.Format("{0}/{1}/{2}", AssetBundleManagerConfig.ServerURL, platformName, AssetBundleManagerConfig.AssetBundleInfoListFileName); var webRequest = UnityWebRequest.Get(url); webRequest.timeout = 300; #if UNITY_2017_2_OR_NEWER yield return(webRequest.SendWebRequest()); #else yield return(webRequest.Send()); #endif while (!webRequest.isDone) { if (webRequest.isNetworkError || webRequest.isHttpError) { Debug.LogError("AssetBundleInfoList Download Error."); webRequest.Dispose(); yield break; } yield return(null); } if (webRequest.responseCode != 200) { Debug.LogErrorFormat("Respose Error : Code = {0}", webRequest.responseCode); yield break; } this.assetBundleInfoList = JsonUtility.FromJson <AssetBundleInfoList>(webRequest.downloadHandler.text); this.assetBundleInfoList.CreateDictionary(); webRequest.Dispose(); }