Exemplo n.º 1
0
        private void UpdateRequest(PlayAssetPackRequestImpl request, AssetPackState newState, int errorCode)
        {
            if (request.IsDone)
            {
                // Ignore pack state updates associated with completed requests.
                return;
            }

            var assetDeliveryErrorCode = PlayCoreTranslator.TranslatePlayCoreErrorCode(errorCode);

            if (assetDeliveryErrorCode != AssetDeliveryErrorCode.NoError)
            {
                request.OnErrorOccured(assetDeliveryErrorCode);
                return;
            }

            if (newState.Status == PlayCoreTranslator.AssetPackStatus.Canceled)
            {
                request.OnErrorOccured(AssetDeliveryErrorCode.Canceled);
                return;
            }

            request.UpdateState(PlayCoreTranslator.TranslatePlayCorePackStatus(newState.Status),
                                newState.BytesDownloaded,
                                newState.TotalBytesToDownload);
        }
        private void UpdateRequest(
            PlayAssetBundleRequestImpl request,
            AssetPackState newState,
            int errorCode)
        {
            if (request.IsDone)
            {
                // Ignore pack state updates associated with completed requests.
                return;
            }

            var assetDeliveryErrorCode = PlayCoreTranslator.TranslatePlayCoreErrorCode(errorCode);

            if (assetDeliveryErrorCode != AssetDeliveryErrorCode.NoError)
            {
                request.OnErrorOccured(assetDeliveryErrorCode);
                return;
            }

            if (newState.Status == PlayCoreTranslator.AssetPackStatus.Canceled)
            {
                request.OnErrorOccured(AssetDeliveryErrorCode.Canceled);
                return;
            }

            if (newState.Status == PlayCoreTranslator.AssetPackStatus.Completed)
            {
                var isRequestLoadingAssetBundle = _loadingCoroutinesByName.ContainsKey(request.MainAssetBundleName);
                if (!isRequestLoadingAssetBundle)
                {
                    var startedSuccessfully = StartLoadingAssetBundle(request);
                    if (!startedSuccessfully)
                    {
                        request.OnErrorOccured(AssetDeliveryErrorCode.AssetBundleLoadingError);
                        return;
                    }
                }

                request.OnLoadingStarted();
                return;
            }

            request.UpdateState(PlayCoreTranslator.TranslatePlayCorePackStatus(newState.Status),
                                newState.BytesDownloaded,
                                newState.TotalBytesToDownload);
        }