Google.Play.AssetDelivery.PlayAssetDelivery

Provides methods for retrieving asset packs via the Play Asset Delivery system.

Summary

Public static functions

GetDownloadInfo(IList< string > assetPackNames)
PlayAsyncOperation< IDictionary< string, PlayAssetPackDownloadInfo >, AssetDeliveryErrorCode >
Starts a PlayAsyncOperation to gather download information about the specified asset packs.
GetDownloadSize(string assetPackName)
PlayAsyncOperation< long, AssetDeliveryErrorCode >
Starts a PlayAsyncOperation to determine the download size in bytes of the specified asset pack.
IsDownloaded(string assetPackName)
bool
Returns whether or not the specified asset pack is available on disk.
RemoveAssetPack(string assetPackName)
PlayAsyncOperation< VoidResult, AssetDeliveryErrorCode >
Starts a PlayAsyncOperation to delete the specified asset pack from internal storage.
RetrieveAssetBundleAsync(string assetBundleName)
Starts a PlayAssetBundleRequest to retrieve an asset pack containing only the specified AssetBundle.
RetrieveAssetBundleAsync(string assetBundleName, bool updateIfAvailable)
Starts a PlayAssetBundleRequest to retrieve an asset pack containing only the specified AssetBundle.
RetrieveAssetPackAsync(string assetPackName)
Starts a PlayAssetPackRequest to retrieve the specified asset pack.
RetrieveAssetPackAsync(string assetPackName, bool updateIfAvailable)
Starts a PlayAssetPackRequest to retrieve the specified asset pack.
RetrieveAssetPackBatchAsync(IList< string > assetPackNames)
Starts a PlayAssetPackBatchRequest to retrieve the specified asset packs.
RetrieveAssetPackBatchAsync(IList< string > assetPackNames, bool updateIfAvailable)
Starts a PlayAssetPackBatchRequest to retrieve the specified asset packs.
ShowCellularDataConfirmation()
Shows a confirmation dialog for all currently downloading asset packs that are AssetDeliveryStatus.WaitingForWifi.
ShowConfirmationDialog()
Shows a dialog that asks the user for consent to download packs that are currently in either the AssetDeliveryStatus.RequiresUserConfirmation state or the AssetDeliveryStatus.WaitingForWifi state.

Public static functions

GetDownloadInfo

PlayAsyncOperation< IDictionary< string, PlayAssetPackDownloadInfo >, AssetDeliveryErrorCode > GetDownloadInfo(
  IList< string > assetPackNames
)

Starts a PlayAsyncOperation to gather download information about the specified asset packs.

This includes download size and information about asset pack updates.

Details
Parameters
assetPackNames
A list of asset packs.
Returns
A PlayAsyncOperation with a Dictionary result keyed by asset pack name, containing download info about the specified packs.

GetDownloadSize

PlayAsyncOperation< long, AssetDeliveryErrorCode > GetDownloadSize(
  string assetPackName
)

Starts a PlayAsyncOperation to determine the download size in bytes of the specified asset pack.

If the specified asset pack's delivery mode is install-time, then the download size will always be 0.

IsDownloaded

bool IsDownloaded(
  string assetPackName
)

Returns whether or not the specified asset pack is available on disk.

Details
Parameters
assetPackName
The name of the desired asset pack.
Returns
True if the asset pack is available on disk and false if not.

RemoveAssetPack

PlayAsyncOperation< VoidResult, AssetDeliveryErrorCode > RemoveAssetPack(
  string assetPackName
)

Starts a PlayAsyncOperation to delete the specified asset pack from internal storage.

If the specified asset pack is currently being retrieved, this method will not cancel the retrieval. If the specified asset pack contains any AssetBundles that are already loaded into memory, the AssetBundles will not be unloaded.

Details
Returns
An async operation object used to monitor the asset pack removal. If the files are deleted successfully or if the files don't exist, the returned operation will complete successfully. Otherwise, the operation will complete with an error code.

RetrieveAssetBundleAsync

PlayAssetBundleRequest RetrieveAssetBundleAsync(
  string assetBundleName
)

Starts a PlayAssetBundleRequest to retrieve an asset pack containing only the specified AssetBundle.

Both the AssetBundle and asset pack must share the same name. Downloads the asset pack if it isn't already available on disk.

After download, the contained AssetBundle is loaded into memory before the request completes.

Details
Parameters
assetBundleName
The name of the requested AssetBundle.
Exceptions
ArgumentException
Thrown if there is already an active request with the specified name.
Returns
A request object used to monitor the asynchronous AssetBundle retrieval.

RetrieveAssetBundleAsync

PlayAssetBundleRequest RetrieveAssetBundleAsync(
  string assetBundleName,
  bool updateIfAvailable
)

Starts a PlayAssetBundleRequest to retrieve an asset pack containing only the specified AssetBundle.

Both the AssetBundle and asset pack must share the same name. Downloads the asset pack if it isn't already available on disk.

After download, the contained AssetBundle is loaded into memory before the request completes.

Details
Parameters
assetBundleName
The name of the requested AssetBundle.
updateIfAvailable
If true and the specified pack is already installed, this method will check for a newer version and download it if available.
Exceptions
ArgumentException
Thrown if there is already an active request with the specified name.
Returns
A request object used to monitor the asynchronous AssetBundle retrieval.

RetrieveAssetPackAsync

PlayAssetPackRequest RetrieveAssetPackAsync(
  string assetPackName
)

Starts a PlayAssetPackRequest to retrieve the specified asset pack.

Downloads the asset pack if it isn't already available on disk.

After download, the assets and/or AssetBundles contained in the asset pack are not loaded into memory. To load them see PlayAssetPackRequest.GetAssetLocation or PlayAssetPackRequest.LoadAssetBundleAsync.

Details
Parameters
assetPackName
The name of the requested asset pack.
Returns
A request object used to monitor the asynchronous asset pack retrieval.

RetrieveAssetPackAsync

PlayAssetPackRequest RetrieveAssetPackAsync(
  string assetPackName,
  bool updateIfAvailable
)

Starts a PlayAssetPackRequest to retrieve the specified asset pack.

Downloads the asset pack if it isn't already available on disk.

After download, the assets and/or AssetBundles contained in the asset pack are not loaded into memory. To load them see PlayAssetPackRequest.GetAssetLocation or PlayAssetPackRequest.LoadAssetBundleAsync.

Details
Parameters
assetPackName
The name of the requested asset pack.
updateIfAvailable
If true and the specified pack is already installed, this method will check for a newer version and download it if available.
Returns
A request object used to monitor the asynchronous asset pack retrieval.

RetrieveAssetPackBatchAsync

PlayAssetPackBatchRequest RetrieveAssetPackBatchAsync(
  IList< string > assetPackNames
)

Starts a PlayAssetPackBatchRequest to retrieve the specified asset packs.

Downloads the asset packs if they aren't already available on disk.

After download, the assets and/or AssetBundles contained in the asset pack are not loaded into memory. To load them use PlayAssetPackRequest.GetAssetLocation or PlayAssetPackRequest.LoadAssetBundleAsync on the values of the PlayAssetPackBatchRequest.Requests dictionary.

Details
Parameters
assetPackNames
A list of requested asset packs.
Exceptions
ArgumentException
Throws if assetPackNames contains duplicate entries.
Returns
A request object used to monitor the asynchronous asset pack batch retrieval.

RetrieveAssetPackBatchAsync

PlayAssetPackBatchRequest RetrieveAssetPackBatchAsync(
  IList< string > assetPackNames,
  bool updateIfAvailable
)

Starts a PlayAssetPackBatchRequest to retrieve the specified asset packs.

Downloads the asset packs if they aren't already available on disk.

After download, the assets and/or AssetBundles contained in the asset pack are not loaded into memory. To load them use PlayAssetPackRequest.GetAssetLocation or PlayAssetPackRequest.LoadAssetBundleAsync on the values of the PlayAssetPackBatchRequest.Requests dictionary.

Details
Parameters
assetPackNames
A list of requested asset packs.
updateIfAvailable
If true and any of the specified packs are already installed, this method will check for newer versions of them and download them if available.
Exceptions
ArgumentException
Throws if assetPackNames contains duplicate entries.
Returns
A request object used to monitor the asynchronous asset pack batch retrieval.

ShowCellularDataConfirmation

PlayAsyncOperation< ConfirmationDialogResult, AssetDeliveryErrorCode > ShowCellularDataConfirmation()

Shows a confirmation dialog for all currently downloading asset packs that are AssetDeliveryStatus.WaitingForWifi.

If the user accepts the dialog, then those asset packs are downloaded over cellular data.

A PlayAssetBundleRequest is set to AssetDeliveryStatus.WaitingForWifi if the user is currently not on a Wi-Fi connection and the AssetBundle is large or the user has set their download preference in the Play Store to only download apps over Wi-Fi. By showing this dialog, the app can ask the user if they accept downloading the asset packs over cellular data instead of waiting for Wi-Fi.

Details
Returns
A PlayAsyncOperation{ConfirmationDialogResult, AssetDeliveryErrorCode} that completes once the dialog has been accepted, denied, or closed.

ShowConfirmationDialog

PlayAsyncOperation< ConfirmationDialogResult, AssetDeliveryErrorCode > ShowConfirmationDialog()

Shows a dialog that asks the user for consent to download packs that are currently in either the AssetDeliveryStatus.RequiresUserConfirmation state or the AssetDeliveryStatus.WaitingForWifi state.

A PlayAssetBundleRequest is set to AssetDeliveryStatus.RequiresUserConfirmation If the download is not able to proceed without user consent. By showing this dialog, the app can ask the user if they accept downloading the asset packs through GooglePlay. If the app has not been installed by Play, an update may be triggered to ensure that a valid version is installed. This will cause the app to restart and all asset requests to be cancelled. These assets should be requested again after the app restarts.

A PlayAssetBundleRequest is set to AssetDeliveryStatus.WaitingForWifi if the user is currently not on a Wi-Fi connection and the AssetBundle is large or the user has set their download preference in the Play Store to only download apps over Wi-Fi. By showing this dialog, the app can ask the user if they accept downloading the asset packs over cellular data instead of waiting for Wi-Fi.

Details
Returns
A PlayAsyncOperation{ConfirmationDialogResult, AssetDeliveryErrorCode} that completes once the dialog has been accepted, denied, or closed.