private void plotPerformanceGraphToolStripMenuItem_Click(object sender, EventArgs e) { mainGraph.Series.Clear(); channelCollection.Channels.Clear(); // frame time channel { List <DataPoint> points = new List <DataPoint>(); foreach (FrameStats stat in frameData.FrameStats) { points.Add(new DataPoint(stat.FrameId, stat.FrameProcessingTime)); } GraphChannel channel = new GraphChannel("Frame Time", mainGraph, points, GraphChannel.Axis.PrimaryAxis); channelCollection.Channels.Add(channel); } // frame time step { List <DataPoint> points = new List <DataPoint>(); foreach (FrameStats stat in frameData.FrameStats) { points.Add(new DataPoint(stat.FrameId, stat.ConsumedFrameTime)); } GraphChannel channel = new GraphChannel("Time step", mainGraph, points, GraphChannel.Axis.SecondaryAxis); channelCollection.Channels.Add(channel); } graphChannelPropertyGrid.SelectedObject = channelCollection; }
void OnGUI() { if (Event.current.type != EventType.Repaint) { return; } if (Graph.channel[0] == null) { return; } int W = (int)this.position.width; int H = (int)this.position.height; CreateLineMaterial(); lineMaterial.SetPass(0); GL.PushMatrix(); GL.LoadPixelMatrix(); GL.Begin(GL.LINES); for (int chan = 0; chan < Graph.MAX_CHANNELS; chan++) { GraphChannel C = Graph.channel[chan]; if (!C.isActive) { continue; } GL.Color(C._color); for (int h = 0; h < Graph.MAX_HISTORY; h++) { int xPix = (W - 1) - h; if (xPix >= 0) { float y = C._data[h]; float y_01 = Mathf.InverseLerp(Graph.YMin, Graph.YMax, y); int yPix = (int)(y_01 * H); Plot(xPix, yPix); } } } GL.End(); GL.PopMatrix(); }