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 OnStateUpdateReceived(AssetPackState newState)
        {
            if (_gettingPackStates)
            {
                _stateUpdatesSinceGetPackStates.Add(newState.Name);
            }

            OnStateUpdateEvent.Invoke(newState);
        }
Exemplo n.º 3
0
        private void ProcessPackStateUpdate(AssetPackState newState)
        {
            PlayAssetPackRequestImpl request;

            if (!_requestRepository.TryGetRequest(newState.Name, out request))
            {
                Debug.LogWarningFormat(
                    "Received state update \"{0}\", that is not associated with an active request.",
                    newState.Name);
                return;
            }

            UpdateRequest(request, newState, newState.ErrorCode);
        }
        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);
        }
Exemplo n.º 5
0
        // Proxied java calls. Method names are camelCase to match the corresponding java methods.
        public void onStateUpdate(AndroidJavaObject assetPacksState)
        {
            var packState = new AssetPackState(assetPacksState);

            PlayCoreEventHandler.HandleEvent(() => OnStateUpdateEvent.Invoke(packState));
        }