public DownloadSizeAsyncOperation(IList <string> assetPacks) { assetPackSizeOperations = new List <PlayAsyncOperation <long, AssetDeliveryErrorCode> >(); foreach (string assetPack in assetPacks) { // check if the asset pack was already downloaded either during install or previous launch. if (PlayAssetDelivery.IsDownloaded(assetPack)) { Debug.LogFormat("[{0}] Assetpack={1} Already downloaded", nameof(DownloadSizeAsyncOperation), assetPack); continue; } PlayAsyncOperation <long, AssetDeliveryErrorCode> sizeOperation = PlayAssetDelivery.GetDownloadSize(assetPack); assetPackSizeOperations.Add(sizeOperation); if (sizeOperation.IsDone) { OnGetPackDownloadSize(sizeOperation); continue; } sizeOperation.Completed += OnGetPackDownloadSize; } // No Asset packs needed to be updated. if (assetPackSizeOperations.Count == 0) { Complete(AsyncOperationStatus.Succeeded); } }
private void StartAssetPackSizeQuery() { var getSizeOperation = PlayAssetDelivery.GetDownloadSize(assetPackName); getSizeOperation.Completed += (operation) => { if (operation.Error != AssetDeliveryErrorCode.NoError) { Debug.LogErrorFormat("Error getting download size for {0}: {1}", assetPackName, operation.Error); return; } assetPackSize = operation.GetResult(); isAssetPackSizeValid = true; }; }
private void DisplayDownloadSize() { var getSizeOperation = PlayAssetDelivery.GetDownloadSize(AssetBundleName); getSizeOperation.Completed += (operation) => { if (operation.Error != AssetDeliveryErrorCode.NoError) { Debug.LogErrorFormat("Error getting download size for {0}: {1}", AssetBundleName, operation.Error); return; } IsInitialized = true; NameText.text = string.Format("{0} : {1}", AssetBundleName, FormatSize(operation.GetResult())); }; }