这些部分适用于**「fast-follow」和「on-demand」**资产包。
检查状态
每个资产包都存储在应用程序内部存储的单独文件夹中。使用该 「isDownloaded()」 方法确定是否已下载资产包。
监控下载
查询PlayAssetBundleRequest 监控请求状态的 对象:
// Download progress of request, between 0.0f and 1.0f. The value will always be
// 1.0 for assets delivered as install-time.
// NOTE: A value of 1.0 will only signify the download is complete. It will still need to be loaded.
float progress = bundleRequest.DownloadProgress;
// Returns true if:
// * it had either completed the download, installing, and loading of the AssetBundle,
// * OR if it has encountered an error.
bool done = bundleRequest.IsDone;
// Returns status of retrieval request.
AssetDeliveryStatus status = bundleRequest.Status;
switch(status) {
case AssetDeliveryStatus.Pending:
// Asset pack download is pending - N/A for install-time assets.
case AssetDeliveryStatus.Retrieving:
// Asset pack is being downloaded and transferred to app storage.
// N/A for install-time assets.
case AssetDeliveryStatus.Available:
// Asset pack is downloaded on disk but NOT loaded into memory.
// For PlayAssetPackRequest(), this indicates that the request is complete.
case AssetDeliveryStatus.Loading:
// Asset pack is being loaded.
case AssetDeliveryStatus.Loaded:
// Asset pack has finished loading, assets can now be loaded.
// For PlayAssetBundleRequest(), this indicates that the request is complete.
case AssetDeliveryStatus.Failed:
// Asset pack retrieval has failed.
case AssetDeliveryStatus.WaitingForWifi:
// Asset pack retrieval paused until either the device connects via Wi-Fi,
// or the user accepts the PlayAssetDelivery.ShowCellularDataConfirmation dialog.
default:
break;
}
大量下载