public void SetStatus(AssetDeliveryStatus status, AssetDeliveryErrorCode error) { StatusText.text = status.ToString(); if (_buttonsByStatus.ContainsKey(status)) { ShowButtons(_buttonsByStatus[status].ToArray()); } else { HideButtons(); ColorTint.color = NeutralColor; } if (_colorsByStatus.ContainsKey(status)) { ColorTint.color = _colorsByStatus[status]; } if (error != AssetDeliveryErrorCode.NoError) { StatusText.text = string.Format("{0}: {1}", status.ToString(), error.ToString()); RetrieveButtonText.text = "Try Again"; } }
public PlayAssetBundleRequestImpl(PlayAssetPackRequestImpl packRequest, AssetDeliveryUpdateHandler updateHandler) { PackRequest = packRequest; _updateHandler = updateHandler; _loadingStatus = AssetDeliveryStatus.Pending; _loadingError = AssetDeliveryErrorCode.NoError; PackRequest.Completed += OnPackRequestCompleted; }
private void OnLoadingFinished(AssetBundle loadedAssetBundle) { if (IsDone) { return; } DownloadProgress = 1f; AssetBundle = loadedAssetBundle; _loadingStatus = AssetDeliveryStatus.Loaded; IsDone = true; InvokeCompletedEvent(); }
private void OnLoadingErrorOccurred(AssetDeliveryErrorCode errorCode) { if (IsDone) { return; } IsDone = true; _loadingError = errorCode; _loadingStatus = AssetDeliveryStatus.Failed; AssetBundle = null; InvokeCompletedEvent(); }
/// <summary> /// Configure the display so that a button appears when the status changes. /// </summary> public void BindButton(Button button, AssetDeliveryStatus status) { List <Button> buttonsForStatus; if (!_buttonsByStatus.TryGetValue(status, out buttonsForStatus)) { buttonsForStatus = new List <Button>(); _buttonsByStatus.Add(status, buttonsForStatus); } buttonsForStatus.Add(button); _allButtons.Add(button); }
public void UpdateState(AssetDeliveryStatus status, long bytesDownloaded, long totalBytesToDownload) { if (totalBytesToDownload == 0L) { bool finishedDownloading = status == AssetDeliveryStatus.Loading || status == AssetDeliveryStatus.Loaded; DownloadProgress = finishedDownloading ? 1f : 0f; } else { DownloadProgress = bytesDownloaded / (float)totalBytesToDownload; } Status = status; }
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(); } }
private void SetStatus(AssetDeliveryStatus status, AssetDeliveryErrorCode error) { StatusText.text = status.ToString(); switch (status) { case AssetDeliveryStatus.Pending: case AssetDeliveryStatus.Retrieving: ShowButtons(CancelDownloadButton); ColorTint.color = NeutralColor; break; case AssetDeliveryStatus.WaitingForWifi: ShowButtons(ShowCellularDialogButton); ColorTint.color = NeutralColor; break; case AssetDeliveryStatus.Loading: HideButtons(); ColorTint.color = NeutralColor; break; case AssetDeliveryStatus.Loaded: ShowButtons(LoadSceneButton, RemoveButton); ColorTint.color = SuccessColor; break; case AssetDeliveryStatus.Failed: ShowButtons(RetrieveAssetBundleButton); ColorTint.color = ErrorColor; break; default: HideButtons(); ColorTint.color = NeutralColor; break; } if (error != AssetDeliveryErrorCode.NoError) { StatusText.text = string.Format("{0}: {1}", status.ToString(), error.ToString()); RetrieveAssetBundleButtonText.text = "Try Again"; } }
private void StartLoadingAssetBundle() { _updateHandler.StartCoroutine(CoLoadAssetBundle()); DownloadProgress = 1f; _loadingStatus = AssetDeliveryStatus.Loading; }
public IList <PlayAssetPackRequestImpl> GetRequestsWithStatus(AssetDeliveryStatus status) { return(_requestsByName.Values.Where(request => request.Status == status).ToList()); }
/// <summary> /// Configure the display so that the loading bar color changes when the status is set to the specified one. /// </summary> public void BindColor(Color color, AssetDeliveryStatus status) { _colorsByStatus.Add(status, color); }