private void createUI() { Toolbar toolbar = AddControl <Toolbar>(); { Label label = toolbar.AddControl <Label>(); { label.Content.Text = "Update Rate: "; label.Layout.Size = new Vector2(0, 0); } ToggleButton slow = toolbar.AddControl <ToggleButton>("0"); { slow.Style = new VisualStyle(EditorStyle.ToolbarButton); slow.Content.Text = "Slow Update"; slow.Content.Tooltip = "Set the refresh mode to slow. Less updates per frame"; slow.OnClicked += (object sender) => { setUpdateRate(0); }; } ToggleButton medium = toolbar.AddControl <ToggleButton>("1"); { medium.Style = new VisualStyle(EditorStyle.ToolbarButton); medium.Content.Text = "Medium Update"; medium.Content.Tooltip = "Set the refresh mode to medium. The default settings"; medium.OnClicked += (object sender) => { setUpdateRate(1); }; } ToggleButton fast = toolbar.AddControl <ToggleButton>("2"); { fast.Style = new VisualStyle(EditorStyle.ToolbarButton); fast.Content.Text = "Fast Update"; fast.Content.Tooltip = "Set the refresh mode to fast. More updates per frames for more accurate data"; fast.OnClicked += (object sender) => { setUpdateRate(2); }; } toolbar.AddControl <FlexibleSpacer>(); // Set the mode setUpdateRate(-1); } parent = AddControl <VerticalLayout>(); { HelpBox timingHelp = parent.AddControl <HelpBox>(); { timingHelp.Content.Text = "Shows the average and peek time taken to complete the algorithm"; } Chart timingChart = parent.AddControl <Chart>(); { timingChart.Layout.MinSize = new Vector2(0, 0); timingChart.SetChartAxis(ChartAxis.Horizontal, 0, 1, "Update (Frame Step)"); timingChart.SetChartAxis(ChartAxis.Vertical, 0, 1, "Time (ms)"); timingChart.SetDatasetCount(2); timingChart.SetDataset(0, timingData); timingChart.SetDataset(1, timingPeekData); timingData.Name = "Average Time (Per sample)"; timingPeekData.Name = "Highest Time (Per sample)"; } HelpBox usageHelp = parent.AddControl <HelpBox>(); { usageHelp.Content.Text = "Shows the current usages value for all worker threads (When active)"; } HorizontalLayout usageLayout = parent.AddControl <HorizontalLayout>(); { Chart usageChart = usageLayout.AddControl <Chart>(); { usageChart.Layout.MinSize = new Vector2(0, 0); usageChart.SetChartAxis(ChartAxis.Horizontal, 0, 1, "Update (Frame Step)"); usageChart.SetChartAxis(ChartAxis.Vertical, 0, 1, "Usage (%)"); // Set data usageChart.SetDatasetCount(3); for (int i = 0; i < ThreadManager.maxAllowedWorkerThreads; i++) { usageData[i] = new ChartDynamicDataset(); usageData[i].Name = string.Format("Thread {0}", i + 1); usageChart.SetDataset(i, usageData[i]); } } usageView = usageLayout.AddControl <ThreadViewCollectionControl>(); { usageView.Layout.Size = new Vector2(230, 0); } } } hint = AddControl <HelpBox>(); { hint.HelpType = HelpBoxType.Info; hint.Content.Text = "Waiting for game to launch. Timing and usage statistics can only be gathered in play mode"; } }