private void StartDownload() { Debug.Log("Downloading bundletool..."); _downloadRequest = GooglePlayInstantUtils.StartFileDownload( Bundletool.BundletoolDownloadUrl, Bundletool.BundletoolJarPath); }
private void HandlePluginDownloadRequestIsDone() { if (GooglePlayInstantUtils.IsNetworkError(_pluginDownloadRequest)) { var downloadRequestError = _pluginDownloadRequest.error; Debug.LogErrorFormat("Plugin download error: {0}", downloadRequestError); EditorUtility.DisplayDialog("Download Failed", downloadRequestError, WindowUtils.OkButtonText); return; } GooglePlayInstantUtils.FinishFileDownload(_pluginDownloadRequest, _latestReleaseSavePath); Debug.LogFormat("Plugin downloaded: {0}", _latestReleaseSavePath); if (_shouldInstallPlugin) { AssetDatabase.ImportPackage(_latestReleaseSavePath, true); } else { var message = string.Format( "The plugin has been downloaded: {0}\n\nClick \"{1}\" to locate the file in the {2}.", _latestReleaseSavePath, WindowUtils.OkButtonText, Application.platform == RuntimePlatform.WindowsEditor ? "file explorer" : "finder"); if (EditorUtility.DisplayDialog( "Download Complete", message, WindowUtils.OkButtonText, WindowUtils.CancelButtonText)) { EditorUtility.RevealInFinder(_latestReleaseSavePath); } EditorApplication.delayCall += Close; } }
private void StartVersionCheck() { Debug.Log("Checking for latest plugin version..."); _latestReleaseVersion = null; _latestReleaseDownloadUrl = null; _versionCheckRequest = UnityWebRequest.Get(LatestReleaseQueryUrl); GooglePlayInstantUtils.SendWebRequest(_versionCheckRequest); }
private static AsyncOperation StartAssetBundleDownload(string assetBundleUrl, out UnityWebRequest webRequest) { #if UNITY_2018_1_OR_NEWER webRequest = UnityWebRequestAssetBundle.GetAssetBundle(assetBundleUrl); #else webRequest = UnityWebRequest.GetAssetBundle(assetBundleUrl); #endif return(GooglePlayInstantUtils.SendWebRequest(webRequest)); }
private void StartDownload() { Debug.Log("Downloading bundletool..."); var bundletoolUri = string.Format( "https://github.com/google/bundletool/releases/download/{0}/bundletool-all-{0}.jar", Bundletool.BundletoolVersion); _downloadRequest = GooglePlayInstantUtils.StartFileDownload(bundletoolUri, Bundletool.GetBundletoolJarPath()); }
private void SetScore(int newScore) { _score = newScore; #if !UNITY_EDITOR Debug.Log("Is instant app: " + GooglePlayInstantUtils.IsInstantApp()); #endif Debug.Log("before setting level " + (_score % MAX_SCORE_PER_LEVEL > 0)); if (_score != 0 && _score % MAX_SCORE_PER_LEVEL == 0) { IncrementLevel(); } UpdateScoreDisplay(); }
private IEnumerator GetAssetBundle(string assetBundleUrl) { UnityWebRequest webRequest; var downloadOperation = StartAssetBundleDownload(assetBundleUrl, out webRequest); yield return(LoadingBar.FillUntilDone(downloadOperation, _maxLoadingBarProgress, LoadingBar.AssetBundleDownloadToInstallRatio, true)); if (GooglePlayInstantUtils.IsNetworkError(webRequest)) { _maxLoadingBarProgress = LoadingBar.Progress; Debug.LogFormat("Failed to download AssetBundle: {0}", webRequest.error); } else { _bundle = DownloadHandlerAssetBundle.GetContent(webRequest); } }
private void Update() { if (_downloadRequest == null) { return; } if (_downloadRequest.isDone) { EditorUtility.ClearProgressBar(); if (GooglePlayInstantUtils.IsNetworkError(_downloadRequest)) { var downloadRequestError = _downloadRequest.error; _downloadRequest.Dispose(); _downloadRequest = null; Debug.LogErrorFormat("Bundletool download error: {0}", downloadRequestError); if (EditorUtility.DisplayDialog("Download Failed", string.Format("{0}\n\nClick \"{1}\" to retry.", downloadRequestError, WindowUtils.OkButtonText), WindowUtils.OkButtonText, WindowUtils.CancelButtonText)) { StartDownload(); } else { EditorApplication.delayCall += Close; } return; } // Download succeeded. var bundletoolJarPath = Bundletool.BundletoolJarPath; GooglePlayInstantUtils.FinishFileDownload(_downloadRequest, bundletoolJarPath); _downloadRequest.Dispose(); _downloadRequest = null; Debug.LogFormat("Bundletool downloaded: {0}", bundletoolJarPath); var message = string.Format( "Bundletool has been downloaded to your project's \"Library\" directory: {0}", bundletoolJarPath); if (EditorUtility.DisplayDialog("Download Complete", message, WindowUtils.OkButtonText)) { EditorApplication.delayCall += Close; } return; } // Download is in progress. if (EditorUtility.DisplayCancelableProgressBar( "Downloading bundletool", null, _downloadRequest.downloadProgress)) { EditorUtility.ClearProgressBar(); _downloadRequest.Abort(); _downloadRequest.Dispose(); _downloadRequest = null; Debug.Log("Cancelled bundletool download."); } }
private void HandleVersionCheckRequestIsDone() { if (GooglePlayInstantUtils.IsNetworkError(_versionCheckRequest)) { HandleVersionCheckFailed(_versionCheckRequest.error, null); return; } var responseText = _versionCheckRequest.downloadHandler.text; LatestReleaseResponse latestReleaseResponse; try { latestReleaseResponse = JsonUtility.FromJson <LatestReleaseResponse>(responseText); } catch (ArgumentException ex) { HandleVersionCheckFailed(ex.Message, responseText); return; } if (latestReleaseResponse == null) { HandleVersionCheckFailed("Response missing.", responseText); return; } if (string.IsNullOrEmpty(latestReleaseResponse.tag_name)) { HandleVersionCheckFailed("Latest release version is missing.", responseText); return; } var latestReleaseAssets = latestReleaseResponse.assets; if (latestReleaseAssets == null) { HandleVersionCheckFailed("Latest release assets are null.", responseText); return; } if (latestReleaseAssets.Length == 0) { HandleVersionCheckFailed("Latest release assets are empty.", responseText); return; } if (latestReleaseAssets.Length > 1) { HandleVersionCheckFailed(string.Format( "Latest release unexpectedly has {0} asset files.", latestReleaseAssets.Length), responseText); return; } var latestReleaseAsset = latestReleaseAssets[0]; if (latestReleaseAsset == null) { HandleVersionCheckFailed("Latest release asset is null.", responseText); return; } if (string.IsNullOrEmpty(latestReleaseAsset.browser_download_url)) { HandleVersionCheckFailed("Latest release download URL is missing.", responseText); return; } _latestReleaseVersion = latestReleaseResponse.tag_name; _latestReleaseDownloadUrl = latestReleaseAsset.browser_download_url; Debug.LogFormat("Plugin version check result: current={0} latest={1} url={2}", GooglePlayInstantUtils.PluginVersion, _latestReleaseVersion, _latestReleaseDownloadUrl); }
private void StartPluginDownload() { Debug.LogFormat("Downloading the latest plugin: {0}", _latestReleaseSavePath); _pluginDownloadRequest = GooglePlayInstantUtils.StartFileDownload(_latestReleaseDownloadUrl, _latestReleaseSavePath); }