public static Promise ShowAsync(bool autoClose = true) { var promise = new Promise(); var window = GetWindow <UpdateRuntimeWindow>(utility: true); window.Done += (sender, args) => promise.TrySetCompleted(); window.Cancel += (sender, args) => promise.TrySetFailed(args.GetException()); window.monoPath = string.IsNullOrEmpty(MonoRuntimeInformation.MonoPath) ? MonoRuntimeInformation.MonoDefaultLocation : MonoRuntimeInformation.MonoPath; window.autoClose = autoClose; if (RuntimeInformation.IsWindows) { window.runtimeVersion = DotNetRuntimeInformation.GetVersion(); } window.RunCheck(); window.Focus(); if (Settings.Current.Verbose) { Debug.Log(string.Format("Showing '{0}' window. Where current mono location: '{1}'.", window.titleContent.text, window.monoPath)); } return(promise); }
private IEnumerable CheckRuntimeVersionAsync() { if (RuntimeInformation.IsWindows) { var dotNetRuntimeVersion = DotNetRuntimeInformation.GetVersion(); if (dotNetRuntimeVersion != null) { this.UpdateRuntimeVersionLabel(dotNetRuntimeVersion, ".NET", true); this.RaiseDone(monoRuntimePath: null); yield break; } } var monoRuntimePath = File.Exists(this.monoPath) ? this.monoPath : Path.Combine(this.monoPath, MonoRuntimeInformation.MonoExecutableName); if (string.IsNullOrEmpty(monoRuntimePath)) { yield break; } this.runtimeVersion = Resources.UI_UNITYPLUGIN_WINDOW_CHECKING_MONO; this.runMonoTask = CommandLine.Run(new RunOptions(monoRuntimePath, "--version") { CaptureStandardOutput = true, CaptureStandardError = true, ExecutionTimeout = TimeSpan.FromSeconds(5) }); yield return(this.runMonoTask.IgnoreFault()); var output = string.Empty; if (this.runMonoTask.HasErrors == false) { output = this.runMonoTask.GetResult().GetOutputData() ?? ""; } var monoRuntimeVersionMatch = CharonCli.MonoVersionRegex.Match(output); if (!monoRuntimeVersionMatch.Success) { if (Settings.Current.Verbose) { Debug.LogWarning(output.Length > 0 ? output : string.Format(Resources.UI_UNITYPLUGIN_WINDOW_CHECKING_MONO_FAILED, this.runMonoTask.GetResult().ExitCode)); } this.UpdateRuntimeVersionLabel(Resources.UI_UNITYPLUGIN_WINDOW_RUNTIME_VERSION_UNKNOWN, "Mono", isValid: false); } else { try { var monoRuntimeVersion = new Version(monoRuntimeVersionMatch.Groups["v"].Value); this.runtimeVersion = monoRuntimeVersion + " (Mono)"; if (monoRuntimeVersion >= CharonCli.MinimalMonoVersion) { this.RaiseDone(monoRuntimePath); } else { this.UpdateRuntimeVersionLabel(monoRuntimeVersion.ToString(), "Mono", isValid: false); } } catch (Exception e) { if (Settings.Current.Verbose) { Debug.LogError(e); } this.UpdateRuntimeVersionLabel(Resources.UI_UNITYPLUGIN_WINDOW_RUNTIME_VERSION_ERROR, "Mono", isValid: false); } } }