/// <summary> /// 非同期でアセットバンドルの読み込みを行う /// </summary> /// <param name="filePath"></param> /// <returns></returns> private static async UniTask <bool> LoadAssetBundleAsync(string filePath) { // アセットバンドル読み込み用のパスに変更してリクエストを行う var request = GetAssetBundleRequest( ResourcePathUtility.GetAssetBundleRequestPath(filePath)); await request; if (request.Result.isHttpError || request.Result.isNetworkError) { Debug.LogError(request.Result.error + ":" + request.Result.url); return(false); } // 読み込み済みリストに追加 var assetBundle = DownloadHandlerAssetBundle.GetContent(request.Result); AddLoadedAssetBundles(assetBundle, filePath); return(true); }
/// <summary> /// リソースの一括読み込みを行う /// </summary> /// <param name="resourceNames"></param> public static async UniTask StartBulkLoad(Dictionary <string, EResourceType> resourceNames) { var loadFileList = new List <string>(); foreach (var pair in resourceNames) { var pathWithPrefixAdded = ResourcePathUtility.GetResourcePathWithPrefix(pair.Key, pair.Value); if (!ContainLoadedAssetBundles(pathWithPrefixAdded)) { loadFileList.Add(pathWithPrefixAdded); } } // アセットバンドルの読み込みを並列実行して待機する var loadTasks = new List <UniTask <bool> >(); foreach (var filePath in loadFileList) { loadTasks.Add(LoadAssetBundleAsync(filePath)); } await UniTask.WhenAll(loadTasks); }