async Task <IEnumerable <string> > ListContentsOctokit(string searchTerm, string repoOwner, string repoName, string url) { var client = new GitHubClient(new ProductHeaderValue("Cohee-Creative")); EditorCoroutines.EditorCoroutine currentCoroutine = this.StartCoroutine(CheckTimeOut()); if (!string.IsNullOrEmpty(m_UserName)) { var basicAuth = new Credentials(m_UserName, m_Password); client.Credentials = basicAuth; } var request = new SearchCodeRequest(searchTerm, repoOwner, repoName) { // we can restrict search to the file, path or search both In = new[] { CodeInQualifier.Path }, // how about we find a file based on a certain language Language = Language.CSharp, // we may want to restrict the file based on file extension Extension = "cs", }; var task = await client.Search.SearchCode(request); this.StopCoroutine("CheckTimeOut"); return(task.Items.Select(content => content.HtmlUrl)); }
private void UpdateWindow() { Reset(); coroutine = this.StartCoroutine(GetAppodealSDKData()); GUI.enabled = true; AssetDatabase.Refresh(); }
public void Reset() { if (downloader != null) { downloader.CancelAsync(); return; } if (coroutine != null) { this.StopCoroutine(coroutine.routine); } if (progress > 0) { EditorUtility.ClearProgressBar(); } if (loading > 0) { EditorUtility.ClearProgressBar(); } coroutine = null; downloader = null; internalDependencies = new Dictionary <string, NetworkDependency>(); latestDependencies = new Dictionary <string, NetworkDependency>(); loading = 0f; progress = 0f; }
private void UpdateWindow() { startValPB = EditorApplication.timeSinceStartup; Reset(); coroutine = this.StartCoroutine(GetAppodealSDKData()); GUI.enabled = true; AssetDatabase.Refresh(); }
private IEnumerator DownloadSDK(SdkInfo info) { // Wait one frame so that we don't try to show the progress bar in the middle of OnGUI(). yield return(null); // Track download progress (updated by event callbacks below). bool ended = false; bool cancelled = false; Exception error = null; int oldPercentage = 0, newPercentage = 0; var path = Path.Combine(downloadDir, info.Filename); Debug.LogFormat("Downloading {0} to {1}", info.Url, path); activity = string.Format("Downloading {0}...", info.Filename); progress = 0.01f; // Set > 0 in order to show progress bar. // Hook the certificate-fixer callback to make TLS1.0 work (on some sites, anyway). ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback; // Start the async download job. downloader = new WebClient(); downloader.Encoding = Encoding.UTF8; downloader.DownloadProgressChanged += (sender, args) => { newPercentage = args.ProgressPercentage; }; downloader.DownloadFileCompleted += (sender, args) => { ended = true; cancelled = args.Cancelled; error = args.Error; }; downloader.DownloadFileAsync(new Uri(info.Url), path); // Pause until download done/cancelled/fails, keeping progress bar up to date. while (!ended) { Repaint(); yield return(new WaitUntil(() => ended || newPercentage > oldPercentage)); oldPercentage = newPercentage; progress = oldPercentage / 100.0f; } if (error != null) { Debug.LogError(error); cancelled = true; } // Reset async state so the GUI is operational again. downloader = null; coroutine = null; progress = 0; EditorUtility.ClearProgressBar(); if (!cancelled) { AssetDatabase.ImportPackage(path, true); // OK, got the file, so let the user import it if they want. } else { Debug.Log("Download terminated."); } }
private IEnumerator GetSDKVersions() { activity = "Downloading SDK version manifest..."; var www = new WWW(staging ? stagingURL : manifestURL); yield return(www); // Got the file. Now extract info on latest SDKs available. mopubSdkInfo = new SdkInfo(); sdkInfo.Clear(); var dict = Json.Deserialize(www.text) as Dictionary <string, object>; if (dict != null) { object obj; if (dict.TryGetValue("mopubBaseConfig", out obj)) { mopubSdkInfo.FromJson("Unity SDK", obj as Dictionary <string, object>); mopubSdkInfo.CurrentVersion = MoPub.moPubSDKVersion; } if (dict.TryGetValue("releaseInfo", out obj)) { foreach (var item in obj as Dictionary <string, object> ) { var info = new SdkInfo(); if (info.FromJson(item.Key, item.Value as Dictionary <string, object>)) { sdkInfo[info.Key] = info; } } } } // Figure out what versions of SDKs are currently installed. var baseType = typeof(PackageConfig); var configs = from t in Assembly.GetExecutingAssembly().GetTypes() where t.IsSubclassOf(baseType) && !t.IsAbstract select Activator.CreateInstance(t) as PackageConfig; foreach (var config in configs) { SdkInfo info; sdkInfo.TryGetValue(config.Name, out info); if (info.FromConfig(config)) { sdkInfo[info.Key] = info; } } // Clear up the async-job state. coroutine = null; Repaint(); }
private void CancelOperation() { // Stop any async action taking place. if (downloader != null) { downloader.Abort(); // The coroutine should resume and clean up. return; } if (coroutine != null) { this.StopCoroutine(coroutine.routine); } coroutine = null; downloader = null; }
private IEnumerator DownloadSDK(Sdk sdkInfo) { var path = Path.Combine(DownloadDirectory, sdkInfo.sdkName); _activity = $"Downloading {sdkInfo.sdkName}..."; // Start the async download job. _downloader = new UnityWebRequest(sdkInfo.downloadUrl) { downloadHandler = new DownloadHandlerFile(path), timeout = 60, // seconds }; _downloader.SendWebRequest(); // Pause until download done/cancelled/fails, keeping progress bar up to date. while (!_downloader.isDone) { yield return(null); var progress = Mathf.FloorToInt(_downloader.downloadProgress * 100); if (EditorUtility.DisplayCancelableProgressBar("Elephant SDK Manager", _activity, progress)) { _downloader.Abort(); } } EditorUtility.ClearProgressBar(); if (string.IsNullOrEmpty(_downloader.error)) { if (Directory.Exists(AssetsPathPrefix + sdkInfo.sdkName)) { FileUtil.DeleteFileOrDirectory(AssetsPathPrefix + sdkInfo.sdkName); } AssetDatabase.ImportPackage(path, true); FileUtil.DeleteFileOrDirectory(path); } _downloader.Dispose(); _downloader = null; _editorCoroutine = null; yield return(null); }
public IEnumerator GetSDKVersions() { // Download the manifest from MoPub's status website. current = MoPub.moPubSDKVersion; activity = "Downloading SDK version manifest..."; var www = new WWW(manifestURL); yield return(www); // Got the file. Now extract info on latest SDK available. var json = www.text; var dict = Json.Deserialize(json) as Dictionary <string, object>; object obj; if (dict != null && dict.TryGetValue("mopubBaseConfig", out obj)) { dict = obj as Dictionary <string, object>; } if (dict != null && dict.TryGetValue("Unity", out obj)) { dict = obj as Dictionary <string, object>; } if (dict != null) { if (dict.TryGetValue("version", out obj)) { latest = obj as string; } if (dict.TryGetValue("filename", out obj)) { filename = obj as string; } if (dict.TryGetValue("download_url", out obj)) { packageUrl = obj as string; } } // Clear up the async-job state. coroutine = null; Repaint(); }
private void CancelOperation() { // Stop any async action taking place. if (downloader != null) { downloader.CancelAsync(); // The coroutine should resume and clean up. return; } if (coroutine != null) { this.StopCoroutine(coroutine.routine); } if (progress > 0) { EditorUtility.ClearProgressBar(); } coroutine = null; downloader = null; progress = 0; }
private void CancelOperation() { // Stop any async action taking place. if (_downloader != null) { _downloader.Abort(); // The coroutine should resume and clean up. return; } if (_editorCoroutine != null) { this.StopCoroutine(_editorCoroutine.routine); } if (_editorCoroutineSelfUpdate != null) { this.StopCoroutine(_editorCoroutineSelfUpdate.routine); } _editorCoroutineSelfUpdate = null; _editorCoroutine = null; _downloader = null; }
private void OnEnable() { startValPB = EditorApplication.timeSinceStartup; loading = 0f; coroutine = this.StartCoroutine(GetAppodealSDKData()); }
private IEnumerator DownloadUnityPlugin(string source, string pluginVersion) { yield return(null); var ended = false; var cancelled = false; Exception error = null; int oldPercentage = 0, newPercentage = 0; var path = Path.Combine("Assets/Appodeal", AppodealDependencyUtils.AppodealUnityPlugin + pluginVersion); progress = 0.01f; downloader = new WebClient { Encoding = Encoding.UTF8 }; downloader.DownloadProgressChanged += (sender, args) => { newPercentage = args.ProgressPercentage; }; downloader.DownloadFileCompleted += (sender, args) => { ended = true; cancelled = args.Cancelled; error = args.Error; }; if (!string.IsNullOrEmpty(source)) { Debug.LogFormat("Downloading {0} to {1}", source, path); Debug.Log(source); downloader.DownloadFileAsync(new Uri(source), path); } else { AppodealDependencyUtils.ShowInternalErrorDialog(this, "Can't find internal dependencies.", string.Empty); } while (!ended) { Repaint(); var percentage = oldPercentage; yield return(new WaitUntil(() => ended || newPercentage > percentage)); oldPercentage = newPercentage; progress = oldPercentage / 100.0f; } if (error != null) { Debug.LogError(error); cancelled = true; } downloader = null; coroutine = null; progress = 0; EditorUtility.ClearProgressBar(); if (!cancelled) { AssetDatabase.ImportPackage(path, true); } else { Debug.Log("Download terminated."); } }
private void OnEnable() { loading = 0f; coroutine = this.StartCoroutine(GetAppodealSDKData()); }
public void OnEnable() { _editorCoroutine = this.StartCoroutine(FetchManifest()); _editorCoroutineSelfUpdate = this.StartCoroutine(CheckSelfUpdate()); }
private void CheckVersions() { if (!Directory.Exists(AssetsPathPrefix + "Elephant")) { Sdk elephantSdk = _sdkList.Find(sdk => sdk.sdkName.Equals("Elephant")); elephantSdk.currentVersion = ""; Assembly assemblyForAds = Assembly.GetExecutingAssembly(); foreach (var type in assemblyForAds.GetTypes()) { if (type.FullName == null) { return; } if (type.FullName.Equals("RollicGames.Advertisements.AdsSdkVersion")) { var fieldInfo = type.GetField("SDK_VERSION", BindingFlags.NonPublic | BindingFlags.Static); var adsSDK = _sdkList.Find(sdk => sdk.sdkName.Equals("RollicGames")); if (!(fieldInfo is null)) { adsSDK.currentVersion = fieldInfo.GetValue(null).ToString(); } } } _editorCoroutine = null; Repaint(); return; } Assembly myAssembly = Assembly.GetExecutingAssembly(); foreach (var type in myAssembly.GetTypes()) { if (type.FullName == null) { return; } if (type.FullName.Equals("ElephantSDK.ElephantVersion")) { FieldInfo fieldInfo = type.GetField("SDK_VERSION", BindingFlags.NonPublic | BindingFlags.Static); Sdk elephantSdk = _sdkList.Find(sdk => sdk.sdkName.Equals("Elephant")); if (!(fieldInfo is null)) { elephantSdk.currentVersion = fieldInfo.GetValue(null).ToString(); } } if (type.FullName.Equals("RollicGames.Advertisements.AdsSdkVersion")) { var fieldInfo = type.GetField("SDK_VERSION", BindingFlags.NonPublic | BindingFlags.Static); var adsSDK = _sdkList.Find(sdk => sdk.sdkName.Equals("RollicGames")); if (!(fieldInfo is null)) { adsSDK.currentVersion = fieldInfo.GetValue(null).ToString(); } } } _editorCoroutine = null; Repaint(); }
private IEnumerator DownloadSDK(SdkInfo info) { var path = Path.Combine(downloadDir, info.Filename); activity = string.Format("Downloading {0}...", info.Filename); Debug.Log(activity); // Start the async download job. downloader = new UnityWebRequest(info.Url) { downloadHandler = new DownloadHandlerFile(path), timeout = 60, // seconds }; downloader.SendWebRequest(); // Pause until download done/cancelled/fails, keeping progress bar up to date. while (!downloader.isDone) { yield return(null); var progress = Mathf.FloorToInt(downloader.downloadProgress * 100); if (EditorUtility.DisplayCancelableProgressBar("MoPub SDK Manager", activity, progress)) { downloader.Abort(); } } EditorUtility.ClearProgressBar(); if (string.IsNullOrEmpty(downloader.error)) { AssetDatabase.ImportPackage(path, true); // OK, got the file, so let the user import it if they want. } else { var error = downloader.error; if (downloader.isNetworkError) { if (error.EndsWith("destination host")) { error += ": " + info.Url; } } else if (downloader.isHttpError) { switch (downloader.responseCode) { case 404: var file = Path.GetFileName(new Uri(info.Url).LocalPath); error = string.Format("File {0} not found on server.", file); break; default: error = downloader.responseCode + "\n" + error; break; } } Debug.LogError(error); } // Reset async state so the GUI is operational again. downloader.Dispose(); downloader = null; coroutine = null; }
private IEnumerator GetAppodealSDKData() { yield return(null); #region Internal if (AppodealDependencyUtils.GetInternalDependencyPath() != null) { foreach (var fileInfo in AppodealDependencyUtils.GetInternalDependencyPath()) { if (!File.Exists(AppodealDependencyUtils.Network_configs_path + fileInfo.Name)) { AppodealDependencyUtils.ShowInternalErrorDialog(this, $"File doesn't exist - {AppodealDependencyUtils.Network_configs_path + fileInfo.Name}", string.Empty); } else { GetInternalDependencies(AppodealDependencyUtils.Network_configs_path + fileInfo.Name); } } } else { AppodealDependencyUtils.ShowInternalErrorDialog(this, "Can't find internal dependencies.", string.Empty); } #endregion #region Plugin var requestPlugin = UnityWebRequest.Get(AppodealDependencyUtils.PluginRequest); yield return(requestPlugin.Send()); if (requestPlugin.isError) { Debug.LogError(requestPlugin.error); AppodealDependencyUtils.ShowInternalErrorDialog(this, requestPlugin.error, string.Empty); } else { if (string.IsNullOrEmpty(requestPlugin.downloadHandler.text)) { yield break; } if (AppodealAds.Unity.Api.Appodeal.APPODEAL_PLUGIN_VERSION.Contains("-Beta")) { appodealUnityPlugin = JsonHelper.FromJson <AppodealUnityPlugin>(JsonHelper.fixJson(requestPlugin.downloadHandler.text)) .ToList().FirstOrDefault(x => x.build_type.Equals("beta")); } else { appodealUnityPlugin = JsonHelper.FromJson <AppodealUnityPlugin>(JsonHelper.fixJson(requestPlugin.downloadHandler.text)) .ToList().FirstOrDefault(x => x.build_type.Equals("stable")); } } #endregion #region Adapters var requestAdapters = UnityWebRequest.Get(AppodealDependencyUtils.AdaptersRequest + AppodealDependencyUtils.ReplaceBetaVersion(AppodealAds.Unity.Api .Appodeal.APPODEAL_PLUGIN_VERSION)); yield return(requestAdapters.Send()); if (requestAdapters.isError) { Debug.LogError(requestAdapters.error); AppodealDependencyUtils.ShowInternalErrorDialog(this, requestAdapters.error, string.Empty); } else { if (string.IsNullOrEmpty(requestAdapters.downloadHandler.text)) { yield break; } if (requestAdapters.downloadHandler.text.Contains("error")) { AppodealDependencyUtils.ShowInternalErrorDialog(this, $"Can't find network configs by {AppodealAds.Unity.Api.Appodeal.APPODEAL_PLUGIN_VERSION} version", string.Empty); yield break; } var networkDependencies = JsonHelper.FromJson <NetworkDependency>( JsonHelper.fixJson(requestAdapters.downloadHandler.text)); if (networkDependencies.Length > 0) { foreach (var networkDependency in networkDependencies) { if (!string.IsNullOrEmpty(networkDependency.name) && !networkDependency.name.Equals(AppodealDependencyUtils.TwitterMoPub)) { latestDependencies.Add(networkDependency.name, networkDependency); } } } } #endregion coroutine = null; isPluginInfoReady = true; }
void OnEnable() { legacyMoPub = MoPubUpgradeMigration.LegacyMoPubPresent(); legacyMediation = MoPubUpgradeMigration.LegacyMediationPresent(); coroutine = this.StartCoroutine(GetSDKVersions()); }
private IEnumerator GetSDKVersions() { // Wait one frame so that we don't try to show the progress bar in the middle of OnGUI(). yield return(null); activity = "Downloading SDK version manifest..."; UnityWebRequest www = new UnityWebRequest(staging ? stagingURL : manifestURL) { downloadHandler = new DownloadHandlerBuffer(), timeout = 10, // seconds }; yield return(www.SendWebRequest()); if (!string.IsNullOrEmpty(www.error)) { Debug.LogError(www.error); EditorUtility.DisplayDialog( "SDK Manager Service", "The services we need are not accessible. Please consider integrating manually.\n\n" + "For instructions, see " + helpLink, "OK"); } var json = www.downloadHandler.text; if (string.IsNullOrEmpty(json)) { json = "{}"; Debug.LogError("Unable to retrieve SDK version manifest. Showing installed SDKs only."); } www.Dispose(); // Got the file. Now extract info on latest SDKs available. mopubSdkInfo = new SdkInfo(); sdkInfo.Clear(); var dict = MJ.Json.Deserialize(json) as Dictionary <string, object>; if (dict != null) { object obj; if (dict.TryGetValue("mopubBaseConfig", out obj)) { mopubSdkInfo.FromJson("Unity SDK", obj as Dictionary <string, object>); mopubSdkInfo.CurrentVersion = MoPub.MoPubSdkVersion; } if (dict.TryGetValue("releaseInfo", out obj)) { foreach (var item in obj as Dictionary <string, object> ) { var info = new SdkInfo(); if (info.FromJson(item.Key, item.Value as Dictionary <string, object>)) { sdkInfo[info.Key] = info; } } } } // Figure out what versions of SDKs are currently installed. var baseType = typeof(PackageConfig); var configs = from t in Assembly.GetExecutingAssembly().GetTypes() where t.IsSubclassOf(baseType) && !t.IsAbstract select Activator.CreateInstance(t) as PackageConfig; foreach (var config in configs) { SdkInfo info; sdkInfo.TryGetValue(config.Name, out info); if (info.FromConfig(config)) { sdkInfo[info.Key] = info; } } // Clear up the async-job state. coroutine = null; Repaint(); }