/// <summary>
        /// Load "sceneassetbundle" and "textureassetbundle" and start the scene.
        /// </summary>
        private IEnumerator DownloadAssetBundles()
        {
            Debug.Log("Starting to retrieve AssetBundle");

            // Asset bundle with a scene:
            var sceneAssetBundleRequest = PlayAssetDelivery.RetrieveAssetBundleAsync("sceneassetbundle");

            // Asset bundle with some textures:
            var textureAssetBundleRequest = PlayAssetDelivery.RetrieveAssetBundleAsync("textureassetbundle");

            while (!sceneAssetBundleRequest.IsDone && !textureAssetBundleRequest.IsDone)
            {
                yield return(null);
            }

            if (sceneAssetBundleRequest.Error != AssetDeliveryErrorCode.NoError)
            {
                Debug.LogErrorFormat("Couldn't load sceneassetbundle: {0}", sceneAssetBundleRequest.Error);
                yield break;
            }

            if (textureAssetBundleRequest.Error != AssetDeliveryErrorCode.NoError)
            {
                Debug.LogErrorFormat("Couldn't load textureassetbundle: {0}", textureAssetBundleRequest.Error);
                yield break;
            }

            var sceneToLoad = sceneAssetBundleRequest.AssetBundle.GetAllScenePaths()[0];

            SceneManager.LoadScene(sceneToLoad);
        }
Beispiel #2
0
 public void StartDownload()
 {
     if (isSingleAssetBundlePack && assetBundleRequest == null)
     {
         assetBundleRequest = PlayAssetDelivery.RetrieveAssetBundleAsync(
             assetPackName);
     }
     else if (!isSingleAssetBundlePack && assetPackRequest == null)
     {
         assetPackRequest = PlayAssetDelivery.RetrieveAssetPackAsync(
             assetPackName);
     }
 }
Beispiel #3
0
        private IEnumerator DownloadAssetBundleCo()
        {
            _request = PlayAssetDelivery.RetrieveAssetBundleAsync(AssetBundleName);

            while (!_request.IsDone)
            {
                if (_request.Status == AssetDeliveryStatus.WaitingForWifi)
                {
                    var asyncOperation = PlayAssetDelivery.ShowCellularDataConfirmation();
                    yield return(asyncOperation); // Wait until user has confirmed or cancelled the dialog.

                    if (asyncOperation.Error != AssetDeliveryErrorCode.NoError ||
                        asyncOperation.GetResult() != ConfirmationDialogResult.Accepted)
                    {
                        // Provide a button to re-show the dialog in case user changes their mind.
                        Display.SetStatus(_request.Status, _request.Error);
                    }

                    yield return(new WaitUntil(() => _request.Status != AssetDeliveryStatus.WaitingForWifi));
                }

                Display.SetProgress(_request.DownloadProgress);
                Display.SetStatus(_request.Status, _request.Error);

                yield return(null);
            }

            Display.SetStatus(_request.Status, _request.Error);

            if (_request.Error != AssetDeliveryErrorCode.NoError)
            {
                Debug.LogErrorFormat("Couldn't load AssetBundles: {0}", _request.Error);
                _request = null;
                yield break;
            }

            _assetBundle = _request.AssetBundle;
            _request     = null;
        }