private void OnGetPackDownloadSize(PlayAsyncOperation <long, AssetDeliveryErrorCode> playAsyncOperation)
        {
            if (!playAsyncOperation.IsSuccessful)
            {
                Debug.LogFormat("[{0}.{1}] Error={2}", nameof(DownloadSizeAsyncOperation), nameof(OnGetPackDownloadSize), playAsyncOperation.Error);
            }

            // Wait until all size operations are completed.
            if (assetPackSizeOperations.Any(operation => !operation.IsDone))
            {
                return;
            }

            // Already completed.
            if (completed)
            {
                return;
            }
            completed = true;

            // At least one operation failed.
            if (!assetPackSizeOperations.All(operation => operation.IsSuccessful))
            {
                AssetDeliveryErrorCode errorCode = assetPackSizeOperations
                                                   .Where(operation => !operation.IsSuccessful)
                                                   .Select(op => op.Error)
                                                   .FirstOrDefault();
                Debug.LogFormat("[{0}.{1}] errorCode={2}", nameof(DownloadSizeAsyncOperation), nameof(OnGetPackDownloadSize), errorCode);
                Complete(AsyncOperationStatus.Failed, new Exception($"Failed to retrieve pending assetPack size {errorCode}"));
            }
            Result = assetPackSizeOperations.Sum(operation => operation.GetResult());
            Debug.LogFormat("[{0}.{1}] downloadSize={2}", nameof(DownloadSizeAsyncOperation), nameof(OnGetPackDownloadSize), Result);
            Complete(AsyncOperationStatus.Succeeded);
        }
        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;
 }
Example #4
0
        public void OnErrorOccured(AssetDeliveryErrorCode errorCode)
        {
            if (IsDone)
            {
                return;
            }

            IsDone = true;
            Error  = errorCode;
            Status = AssetDeliveryStatus.Failed;
            InvokeCompletedEvent();
        }
        private void OnLoadingErrorOccurred(AssetDeliveryErrorCode errorCode)
        {
            if (IsDone)
            {
                return;
            }

            IsDone         = true;
            _loadingError  = errorCode;
            _loadingStatus = AssetDeliveryStatus.Failed;
            AssetBundle    = null;
            InvokeCompletedEvent();
        }
Example #6
0
        public void OnInitializationErrorOccurred(AssetDeliveryErrorCode errorCode)
        {
            foreach (var request in Requests.Values)
            {
                var requestImpl = request as PlayAssetPackRequestImpl;
                if (requestImpl == null)
                {
                    throw new ArgumentException("Request is not a PlayAssetPackRequestImpl");
                }

                requestImpl.OnErrorOccured(errorCode);
            }
        }
        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";
            }
        }