// ------------------------------------------------------------------------------------ // TestViewer // Setup viewer tabs public override TestViewerTabData[] GetViewerTabs(ResultsBase resultsObject) { var typedSettings = (FrameComparisonSettings)logic.GetModel().settings; // Set settings to local type TestViewerTabData[] output = new TestViewerTabData[1]; // Create empty output (mandatory) switch (logic.baselineExists) // Switch on baseline exists { case false: var localResultData = (FrameComparisonResults)resultsObject; // Convert the input results object to this types class (mandatory) output = new TestViewerTabData[2] // Want two tabs { new TestViewerTabData("Results Texture", TestViewerTabType.Texture, Common.ConvertStringToTexture("Tab_ResultsFrame", localResultData.resultFrame), null), // And the results texture new TestViewerTabData("Live Camera", TestViewerTabType.Camera, typedSettings.captureCamera, null) // Live camera showing capture camera }; break; case true: var comparisonData = (FrameComparisonLogic.ComparisonData)logic.GetComparisonData(resultsObject); // Get the comparison data for this test in this types class (mandatory) SetupMaterial(comparisonData.baselineTex, comparisonData.resultsTex); // Setup the material output = new TestViewerTabData[3] // Want three tabs { new TestViewerTabData("Results", TestViewerTabType.TextureSlider, new TestViewer.TextureSliderContext(comparisonData.resultsTex, "Result", comparisonData.baselineTex, "Baseline"), new TestViewerTabData.TestViewerTabStatistic[] // Create slider tab for results/baseline { new TestViewerTabData.TestViewerTabStatistic("Diff", comparisonData.DiffPercentage.ToString()) // Enable the statistics window and display the diff }), new TestViewerTabData("Comparison", TestViewerTabType.Material, material, new TestViewerTabData.TestViewerTabStatistic[] // And the material for the comparison display { new TestViewerTabData.TestViewerTabStatistic("Diff", comparisonData.DiffPercentage.ToString()) // Enable the statistics window and display the diff }), new TestViewerTabData("Live Camera", TestViewerTabType.Camera, typedSettings.captureCamera, null) // Live camera showing capture camera }; break; } return(output); // Return }
// Sets the viewers content public void SetContext(TestViewerTabData tabData) { Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Settings context for type " + tabData.tabType); // Write to console ResetContext(); // Reset context switch (tabData.tabType) // Switch based on tab type { case TestViewerTabType.DefaultCamera: break; case TestViewerTabType.Camera: SetCameraValues(tabData); // Set camera values break; case TestViewerTabType.Texture: textureImage.texture = (Texture2D)tabData.tabObject; // Set image texture textureImage.gameObject.SetActive(true); // Enable image break; case TestViewerTabType.Material: textureImage.material = (Material)tabData.tabObject; // Set image material textureImage.texture = textureImage.material.GetTexture("_MainTex"); // Set image texture textureImage.gameObject.SetActive(true); // Enable image break; case TestViewerTabType.TextureSlider: testViewerSlider.SetContext((TextureSliderContext)tabData.tabObject); // Set slider context testViewerSlider.SetState(true); // Enable slider break; case TestViewerTabType.MaterialSlider: testViewerSlider.SetContext((MaterialSliderContext)tabData.tabObject); // Set slider context testViewerSlider.SetState(true); // Enable slider break; } }
// ------------------------------------------------------------------------------------ // TestViewer // Setup viewer tabs public override TestViewerTabData[] GetViewerTabs(ResultsBase resultsObject) { TestViewerTabData[] output = new TestViewerTabData[1]; // Create empty output (mandatory) var localResultData = (AverageFrameTimeResults)resultsObject; // Convert the input results object to this types class (mandatory) switch (logic.baselineExists) // Switch on baseline exists { case false: output = new TestViewerTabData[1] // Only want one tab { new TestViewerTabData("Live Camera", TestViewerTabType.DefaultCamera, null, new TestViewerTabData.TestViewerTabStatistic[1] // Set the tab to use the default camera { new TestViewerTabData.TestViewerTabStatistic("Average Frame Time", localResultData.avgFrameTime.ToString("N4")) // Enable the statistics window and display the avg frame time }) }; break; case true: var comparisonData = (AverageFrameTimeComparison)logic.ProcessComparison(resultsObject); // Get the comparison data for this test in this types class (mandatory) output = new TestViewerTabData[1] // Only want one tab { new TestViewerTabData("Live Camera", TestViewerTabType.DefaultCamera, null, new TestViewerTabData.TestViewerTabStatistic[2] // Set the tab to use the default camera { new TestViewerTabData.TestViewerTabStatistic("Average Frame Time", localResultData.avgFrameTime.ToString("N4")), // Enable the statistics window and display the avg frame time new TestViewerTabData.TestViewerTabStatistic("Delta", comparisonData.delta.ToString("N4")) // Also display the delta from the comparison }) }; break; } return(output); // Return the tabs }
int tabIndex; // Index for tab // ------------------------------------------------------------------------------------ // Initialization // Setup the tab public void SetupTab(int index, TestViewerTabData data) { Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Setting up tab"); // Write to console tabIndex = index; // Set tab index tabData = data; // Set tab data button = GetComponent <Button>(); // Get button button.onClick.AddListener(delegate { TestViewerNavbar.Instance.OnClickTab(tabIndex); }); // Add listener tabLabel.text = tabData.tabName; // Set tab label }
// Set camera values void SetCameraValues(TestViewerTabData tabData) { Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Setting camera values"); // Write to console if (currentCamera) // If a current camera exists { currentCamera.depth = cameraDepth; // Reset its depth } currentCamera = (Camera)tabData.tabObject; // Get new current camera if (currentCamera) { cameraDepth = currentCamera.depth; // Get current depth currentCamera.depth = 9; // Set its depth } }