private void Update()
        {
            if (_webRequest == null)
            {
                return;
            }

            State = GetStateInfoFromDownload();

            if (State == AssetBundleVerifyState.InProgress)
            {
                if (EditorUtility.DisplayCancelableProgressBar("AssetBundle Download", "",
                                                               _webRequest.downloadProgress))
                {
                    _webRequest.Abort();
                    _webRequest.Dispose();
                    _webRequest = null;

                    Debug.Log("Download process was cancelled.");
                }

                return;
            }

            // Performs download operation only once when webrequest is completed.
            EditorUtility.ClearProgressBar();

            HandleState(State, _webRequest);

            Repaint();

            // Turn request to null to signal ready for next call
            _webRequest.Dispose();
            _webRequest = null;
        }
        // Visible for testing
        internal void HandleState(AssetBundleVerifyState state, UnityWebRequest webRequest)
        {
            // InProgress state should not be handled.
            switch (state)
            {
            case AssetBundleVerifyState.DestinationError:
                AssetBundleDownloadIsSuccessful = false;
                ErrorDescription = "Cannot connect to destination host. See Console log for details.";
                // No need to log since debugging information in this case is logged from thrown exception.
                break;

            case AssetBundleVerifyState.WebRequestError:
                AssetBundleDownloadIsSuccessful = false;
                ErrorDescription = webRequest.error;
                Debug.LogErrorFormat(WebRequestErrorFormatMessage, AssetBundleUrl,
                                     ErrorDescription);
                break;

            case AssetBundleVerifyState.BundleError:
                AssetBundleDownloadIsSuccessful = false;
                ErrorDescription = "Error extracting AssetBundle. See Console log for details.";
                // No need to log since debugging information in this case is automatically logged by Unity.
                break;

            case AssetBundleVerifyState.DownloadSuccess:
                AssetBundleDownloadIsSuccessful = true;
                _numOfMegabytes = ConvertBytesToMegabytes(webRequest.downloadedBytes);
                var scenes = _bundle.GetAllScenePaths();
                _mainScene = (scenes.Length == 0) ? "No scenes in AssetBundle" : scenes[0];
                // Free memory used by the AssetBundle since it will not be in use by the Editor. Set to true to destroy
                // all objects that were loaded from this bundle.
                _bundle.Unload(true);
                break;

            default:
                var errorMessage =
                    string.Format(
                        "Unexpected state while checking the AssetBundle: {0}",
                        state);
                throw new InvalidOperationException(errorMessage);
            }
        }