public void SetReady() { infoStatus = AssetPackInfoStatus.PACKSTATUS_READY; assetPackStatusLabel.text = "Ready"; assetPackDownloadButton.gameObject.SetActive(false); assetPackProgressBar.gameObject.SetActive(false); }
private void Awake() { infoStatus = AssetPackInfoStatus.PACKSTATUS_PENDING; gameAssetManager = GameObject.Find("GameAssetManager").GetComponent <GameAssetManager>(); if (gameAssetManager == null) { Debug.LogError("Failed to find GameAssetManager"); } waitingOnPermissionResult = false; }
private void UpdateDownloading() { if (infoStatus != AssetPackInfoStatus.PACKSTATUS_DOWNLOADING) { infoStatus = AssetPackInfoStatus.PACKSTATUS_DOWNLOADING; SetupDownloadUI(); } AssetDeliveryStatus deliveryStatus = gameAssetPack.GetStatus(); if (deliveryStatus == AssetDeliveryStatus.Failed) { SetupErrorUI(); } else if (deliveryStatus == AssetDeliveryStatus.Loaded || deliveryStatus == AssetDeliveryStatus.Available) { if (gameAssetPack.IsSingleAssetBundlePack) { AssetBundle newBundle = gameAssetPack.FinishBundleDownload(); StartCoroutine(LoadAssetsFromBundle(newBundle)); } else { PlayAssetPackRequest packRequest = gameAssetPack.FinishPackDownload(); LoadAssetsFromPack(packRequest); } } else if (deliveryStatus == AssetDeliveryStatus.Loading) { assetPackStatusLabel.text = "Loading"; assetPackProgressBar.PercentComplete = 1.0f; } else if (deliveryStatus == AssetDeliveryStatus.Retrieving) { assetPackProgressBar.PercentComplete = gameAssetPack.GetDownloadProgress(); } else if (deliveryStatus == AssetDeliveryStatus.WaitingForWifi) { Debug.Log("Download status WaitingForWifi"); infoStatus = AssetPackInfoStatus.PACKSTATUS_NEEDS_PERMISSION; waitingOnPermissionResult = true; gameAssetPack.RequestCellularDataDownload(); } }
public void PermissionResult(bool allow) { if (allow) { infoStatus = AssetPackInfoStatus.PACKSTATUS_DOWNLOADING; SetupDownloadUI(); } else { // If no permission granted, reset UI to allow asking again // by tapping Download UpdatePending(); // But keep us in a needs permission state since we are keeping // the underlying asset pack request live infoStatus = AssetPackInfoStatus.PACKSTATUS_NEEDS_PERMISSION; } }
public void StartDownload() { if (infoStatus == AssetPackInfoStatus.PACKSTATUS_NEEDS_PERMISSION) { if (!waitingOnPermissionResult) { Debug.Log("Cellular data request retry"); waitingOnPermissionResult = true; gameAssetPack.RequestCellularDataDownload(); } } else if (infoStatus == AssetPackInfoStatus.PACKSTATUS_NEEDS_DOWNLOAD) { infoStatus = AssetPackInfoStatus.PACKSTATUS_DOWNLOADING; gameAssetPack.StartDownload(); SetupDownloadUI(); } }
private void UpdatePending() { // We need to wait for the async size request to return the // size of the asset pack if (gameAssetPack.IsAssetPackSizeValid) { assetPackStatusLabel.text = "Needs Download"; infoStatus = AssetPackInfoStatus.PACKSTATUS_NEEDS_DOWNLOAD; long assetPackSize = gameAssetPack.AssetPackSize; float assetPackSizeMB = (float)(((double)assetPackSize) / (1024.0 * 1024.0)); assetPackProgressBar.TotalDownloadSizeInMB = (int)assetPackSizeMB; string downloadText = string.Format("Download {0:0.#} MB", assetPackSizeMB); assetPackDownloadLabel.text = downloadText; assetPackDownloadButton.gameObject.SetActive(true); assetPackProgressBar.gameObject.SetActive(false); } }