private void CaptureQueuedScreenshots() { if (queuedScreenshots.Count == 0) { EditorApplication.update -= CaptureQueuedScreenshots; return; } CustomResolution resolution = queuedScreenshots[0]; if (!resolution.IsActive) { resolution.IsActive = true; if (EditorApplication.isPlaying && EditorApplication.isPaused) { EditorApplication.Step(); // Necessary to refresh overlay UI } } else { try { CaptureScreenshotWithUI(); } catch (Exception e) { Debug.LogException(e); } resolution.IsActive = false; queuedScreenshots.RemoveAt(0); if (queuedScreenshots.Count == 0) { if (EditorApplication.isPlaying && EditorApplication.isPaused) { EditorApplication.Step(); // Necessary to restore overlay UI } if (EditorApplication.isPlaying && setTimeScaleToZero) { Time.timeScale = prevTimeScale; } Debug.Log("<b>Saved screenshots:</b> " + saveDirectory); Repaint(); } else { // Activate the next resolution immediately CaptureQueuedScreenshots(); } } }
public Stream UriToStream(Uri uri) { if (uri.Scheme != "ms-local-stream") { throw new ArgumentException($"{nameof(ContentRootResolver)} should only be used for local stream URIs"); } Console.WriteLine($"Resolving local stream URI {uri}"); var localPath = uri.LocalPath; var frameworkPrefix = "/_framework/"; if (localPath.StartsWith(frameworkPrefix)) { localPath = localPath.Substring(frameworkPrefix.Length); switch (localPath) { case "blazor.desktop.js": return(typeof(ContentRootResolver).Assembly.GetManifestResourceStream("Microsoft.AspNetCore.Components.Desktop.blazor.desktop.js")); default: return(CustomResolution?.Invoke(uri) ?? throw new ArgumentException($"Unknown framework file: {uri}")); } } else if (localPath.StartsWith('/')) { localPath = localPath.Replace('/', Path.DirectorySeparatorChar).Substring(1); var filePath = Path.Combine(ContentRoot.Value, localPath); if (File.Exists(filePath)) { return(File.OpenRead(filePath)); } else { return(CustomResolution?.Invoke(uri) ?? throw new FileNotFoundException($"Local stream URI '{uri}' does not correspond to an existing file on disk", filePath)); } } else { return(CustomResolution?.Invoke(uri) ?? throw new ArgumentException($"Expected local path to start with '/', but received value '{uri.LocalPath}'")); } }
void Start() { CustomResolution currRes = new CustomResolution(Screen.currentResolution); List <string> fullscreenoptions = new List <string>(); foreach (FullScreenMode fsm in typeof(FullScreenMode).GetEnumValues()) { fullscreenoptions.Add(fsm + ""); } fullscreenDropDown.ClearOptions(); fullscreenDropDown.AddOptions(fullscreenoptions); fullscreenDropDown.onValueChanged.AddListener(SetFullscreen); fullscreenDropDown.value = (int)currRes.fullScreenMode; fullscreenDropDown.RefreshShownValue(); resses = new List <string>(); resolutions = new Dictionary <string, CustomResolution>(); foreach (Resolution res in Screen.resolutions) { CustomResolution cres = new CustomResolution(res); if (resolutions.ContainsKey(cres.ToString())) { continue; } string resstring = cres.ToString(); resolutions[resstring] = cres; resses.Add(resstring); } resolutionDropDown.ClearOptions(); resolutionDropDown.AddOptions(resses); resolutionDropDown.value = resses.IndexOf(currRes.ToString()); resolutionDropDown.RefreshShownValue(); resolutionDropDown.onValueChanged.AddListener(OnResolutionChange); masterVolume.onValueChanged.AddListener(MasterVolumeChange); soundEffectVolume.onValueChanged.AddListener(SoundEffectVolumeChange); MasterVolumeChange(50); SoundEffectVolumeChange(50); Load(); }
public void OnResolutionChange(int val) { CustomResolution cr = resolutions[resses[val]]; Screen.SetResolution(cr.width, cr.height, Screen.fullScreenMode, cr.refreshRate); }
private IEnumerator ProcessTestQueue() { Debug.LogFormat("[PlayModeTestRunner] ProcessTestQueueProcess: Mode {0}", RunTestsMode.Mode); ClassNode previousClassNode = null; ITestRunnerCallbackReceiver[] callbackables = TriggerBeforeTestRunEvent(Callbackables); List <MethodNode> methods = null; if (RunTestsMode.Mode == RunTestsMode.RunTestsModeEnum.DoubleClick) { if (!string.IsNullOrEmpty(RunTestsMode.NodeToRunFullName)) { var targetNodes = TestsRootNode.GetChildrenOfType <Node>(true, false, node => { return(node.FullName.Equals(RunTestsMode.NodeToRunFullName, StringComparison.Ordinal)); }); if (targetNodes.Count > 0) { var targetNode = targetNodes[0]; if (targetNode is MethodNode) { methods = new List <MethodNode> { (MethodNode)targetNode }; } else { methods = targetNode.GetChildrenOfType <MethodNode>(); } } } } if (methods == null || methods.Count == 0) { methods = TestsRootNode.GetChildrenOfType <MethodNode>(); } Debug.LogFormat("[PlayModeTestRunner] NonFilteredMethods: {0}", methods.Count); methods = methods.Where(methodNode => { Debug.LogFormat("method data: IsSmoke: {0} isSelected: {1}", methodNode.TestSettings.IsSmoke, methodNode.IsSelected); if (RunTestsMode.Mode == RunTestsMode.RunTestsModeEnum.Smoke && !methodNode.TestSettings.IsSmoke) { return(false); } if (RunTestsMode.Mode == RunTestsMode.RunTestsModeEnum.Selected && !methodNode.IsSelected) { return(false); } if (Namespaces != null && Namespaces.Length > 0) { var result = false; for (int i = 0; i < Namespaces.Length; i++) { var contains = methodNode.FullName.IndexOf(Namespaces[i], StringComparison.OrdinalIgnoreCase) != -1; result |= contains; } return(result); } return(true); }).ToList(); Debug.LogFormat("[PlayModeTestRunner] FilteredMethods: {0}", methods.Count); testInfoData.Total = methods.Count; for (int i = 0; i < methods.Count; i++) { var methodNode = methods[i]; TestStep.Reset(); ClassNode classNode = (ClassNode)methodNode.Parent; Debug.Log("QA: Process " + classNode.Type + " testClass.TestMethods #: " + classNode.Children.Count()); CurrentPlayingMethodNode.UpdateCurrentPlayingNode(methodNode); playModeLogger.Logs.Clear(); if (methodNode.TestSettings.IsIgnored) { ProcessIgnore(methodNode); continue; } for (int repeatTime = 0; repeatTime < RunTestsGivenAmountOfTimes; repeatTime++) { exceptionThrown = false; #if UNITY_EDITOR if (methodNode.TestSettings.EditorTargetResolution != null) { CustomResolution resolution = methodNode.TestSettings.EditorTargetResolution; if (resolution.Width != Screen.width || resolution.Height != Screen.height) { GameViewResizer.SetResolution(resolution.Width, resolution.Height); } } #endif if (!methodNode.TestSettings.ContainsTargetResolution(Screen.width, Screen.height)) { #if UNITY_EDITOR if (methodNode.TestSettings.EditorTargetResolution == null) { Debug.LogWarning(String.Format("PlayModeTestRunner: TARGET RESOLUTION {0}:{1}", methodNode.TestSettings.DefaultTargetResolution.Width, methodNode.TestSettings.DefaultTargetResolution.Height)); GameViewResizer.SetResolution(methodNode.TestSettings.DefaultTargetResolution.Width, methodNode.TestSettings.DefaultTargetResolution.Height); } #else ProcessIgnore(methodNode); continue; #endif } object testInstance = null; screenGUIDrawer.SetCurrentTest(methodNode.FullName); playModeLogger.StartLog(methodNode.FullName); try { testInstance = Activator.CreateInstance(classNode.Type); } catch (Exception ex) { if (classNode.Type == null) { Debug.LogErrorFormat("Can't instantiate class - class type is null." + " class probably was deleted "); } else { Debug.LogErrorFormat("Can't instantiate class \"{0}\". Exception: \"{1}\"", classNode.Type.FullName, ex.Message); } ProcessTestFail(methodNode); continue; } Time.timeScale = DefaultTimescale; Debug.Log("QA: Running testClass: " + classNode.Type); if (classNode != previousClassNode) { previousClassNode = classNode; yield return(RunMethods(classNode.OneTimeSetUpMethods, testInstance, true)); if (exceptionThrown) { Debug.LogError("Fail during executing set up methods."); ProcessTestFail(methodNode); continue; } } yield return(RunMethods(classNode.SetUpMethods, testInstance, true)); if (exceptionThrown) { Debug.LogError("Fail during executing set up methods."); ProcessTestFail(methodNode); continue; } yield return(InvokeTestMethod(testInstance, methodNode)); var exceptionDuringTestMethod = exceptionThrown; exceptionThrown = false; yield return(RunMethods(classNode.TearDownMethods, testInstance, false)); if (i + 1 == methods.Count || methods[i + 1].Parent != classNode) { yield return(RunMethods(classNode.OneTimeTearDownMethods, testInstance, true)); } if (!exceptionDuringTestMethod && exceptionThrown) { Debug.LogError("Fail during executing tear down methods."); ProcessTestFail(methodNode); continue; } if (exceptionDuringTestMethod) { ProcessTestFail(methodNode); continue; } testInfoData.AddSuccess(methodNode.FullName); playModeLogger.EndLog(methodNode.FullName); methodNode.SetTestState(TestState.Passed); methodNode.Logs = playModeLogger.LogsCopy; methodNode.SetStep(TestStep.CurrentIndex); if (OnMethodStateUpdated != null) { OnMethodStateUpdated(); } } } TriggerAfterTestRunEvent(callbackables); FinalizeTest(); }
private void Resolution_SelectedIndexChanged(object sender, EventArgs e) { // MessageBox.Show(((UIComboBox)sender).SelectedItem.ToString()); string callbackSelectedItem = ((UIComboBox)sender).SelectedItem.ToString(); if (callbackSelectedItem == this.currentComboBoxResolution) { return; } switch (resolution.SelectedItem) { case "128x72": resizeWindow(128, 72); browser.ExecuteScriptAsync("document.getElementsByTagName('embed')[0].Zoom(100);"); break; case "1366x768": resizeWindow(1366, 768); browser.ExecuteScriptAsync("document.getElementsByTagName('embed')[0].Zoom(100);"); break; case "1920x1080": resizeWindow(1920, 1080); browser.ExecuteScriptAsync("document.getElementsByTagName('embed')[0].Zoom(100);"); break; case "2560x1440": resizeWindow(2560, 1440); browser.ExecuteScriptAsync("document.getElementsByTagName('embed')[0].Zoom(100);"); break; case "3840x2160": resizeWindow(3840, 2160); browser.ExecuteScriptAsync("document.getElementsByTagName('embed')[0].Zoom(100);"); break; case "7680x4320": resizeWindow(7680, 4320); browser.ExecuteScriptAsync("document.getElementsByTagName('embed')[0].Zoom(100);"); break; case "自定义...": CustomResolution resolution = new CustomResolution(this.Width, this.Height); if (resolution.ShowDialog() == DialogResult.OK) { resizeWindow(resolution.thisWidth, resolution.thisHeight); resolution.Dispose(); } else { Timer tSwitch = new Timer(); tSwitch.Interval = 50; tSwitch.Tick += (senderT, eT) => { this.Activate(); tSwitch.Enabled = false; tSwitch.Dispose(); }; tSwitch.Enabled = true; } break; default: break; } this.currentComboBoxResolution = ((UIComboBox)sender).SelectedItem.ToString(); }