internal void DrawUIPane(IProfilerWindowController win) { if (win.IsRecording()) { GUILayout.Label("Cannot analyze FileIO markers while profiler is recording."); } else { if (!DataPulled) { GUILayout.Label("Select 'Analyze Markers' to view detailed File Access metrics for the captured Profiler data."); return; } int visibleFrameIndex = win.GetActiveVisibleFrameIndex(); if (GetSelectedFrame() != visibleFrameIndex || m_CaptureData.m_FileAccessData.Count == 0 || NewData || ViewSelectionChanged || FrameSelectionChanged) { SetSelectedFrame(visibleFrameIndex); if (selectedViewType == FileIOViewType.Accesses) { UpdateFileAccessTable(); } else if (selectedViewType == FileIOViewType.FileSummary) { CalculateFileSummaries(); UpdateFileSummaryTable(); } ViewSelectionChanged = false; FrameSelectionChanged = false; NewData = false; } string text; if (selectedViewType == FileIOViewType.Accesses) { text = "File accesses: " + m_FileAccessTreeView.GetCount(); } else { text = "Files accessed: " + m_FileSummaryTreeView.GetCount(); } GUILayout.Label(text); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); if (selectedViewType == FileIOViewType.Accesses) { DrawFileAccesses(); } else if (selectedViewType == FileIOViewType.FileSummary) { DrawFileSummaries(); } GUILayout.EndHorizontal(); } }
internal void DrawUIPane(IProfilerWindowController win) { if (win.IsRecording()) { GUILayout.Label("Cannot analyze Asset Loading markers while profiler is recording."); } else { if (!DataPulled) { GUILayout.Label("Select 'Analyze Markers' to view detailed Asset Loading metrics for the captured Profiler data."); return; } int visibleFrameIndex = win.GetActiveVisibleFrameIndex(); if (GetSelectedFrame() != visibleFrameIndex || m_CaptureData.m_AssetLoadMarkers.Count == 0 || FrameSelectionChanged || NewData /*|| ViewSelectionChanged*/) { SetSelectedFrame(visibleFrameIndex); FrameSelectionChanged = false; NewData = false; UpdateAssetMarkerTable(); } string text; if (m_AssetMarkerTreeViewState != null) { text = "Asset Load Markers: " + m_AssetMarkerTreeView.GetCount(); } else { text = ""; } GUILayout.Label(text); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); DrawAssetMarkers(); GUILayout.EndHorizontal(); } }
public void DoGUI(FrameDataView frameDataView, float width, float ypos, float height) { if (frameDataView == null || !frameDataView.IsValid()) { GUILayout.Label(BaseStyles.noData, BaseStyles.label); return; } Rect fullRect = new Rect(0, ypos - 1, width, height + 1); float sideWidth = Chart.kSideWidth - 1; if (Event.current.type == EventType.Repaint) { styles.profilerGraphBackground.Draw(fullRect, false, false, false, false); // The bar in the lower left side that fills the space next to the horizontal scrollbar. EditorStyles.toolbar.Draw(new Rect(0, ypos + height - 15, sideWidth, 15), false, false, false, false); } bool initializing = false; if (m_TimeArea == null) { initializing = true; m_TimeArea = new ZoomableArea(); m_TimeArea.hRangeLocked = false; m_TimeArea.vRangeLocked = true; m_TimeArea.hSlider = true; m_TimeArea.vSlider = false; m_TimeArea.scaleWithWindow = true; m_TimeArea.rect = new Rect(fullRect.x + sideWidth - 1, fullRect.y, fullRect.width - sideWidth, fullRect.height); m_TimeArea.margin = 10; } if (initializing) { NativeProfilerTimeline_InitializeArgs args = new NativeProfilerTimeline_InitializeArgs(); args.Reset(); args.ghostAlpha = 0.3f; args.nonSelectedAlpha = 0.75f; args.guiStyle = styles.bar.m_Ptr; args.lineHeight = kLineHeight; args.textFadeOutWidth = kTextFadeOutWidth; args.textFadeStartWidth = kTextFadeStartWidth; NativeProfilerTimeline.Initialize(ref args); } var iter = new ProfilerFrameDataIterator(); int threadCount = iter.GetThreadCount(frameDataView.frameIndex); iter.SetRoot(frameDataView.frameIndex, 0); m_TimeArea.hBaseRangeMin = 0; m_TimeArea.hBaseRangeMax = iter.frameTimeMS; if (initializing) { PerformFrameSelected(iter.frameTimeMS); } m_TimeArea.rect = new Rect(fullRect.x + sideWidth, fullRect.y, fullRect.width - sideWidth, fullRect.height); m_TimeArea.BeginViewGUI(); m_TimeArea.EndViewGUI(); fullRect = m_TimeArea.drawRect; DrawGrid(fullRect, iter.frameTimeMS); MarkDeadOrClearThread(); CalculateBars(ref iter, fullRect, frameDataView.frameIndex, animationTime); DrawBars(fullRect, frameDataView.frameIndex); DoRangeSelection(m_TimeArea.drawRect); GUI.BeginClip(m_TimeArea.drawRect); fullRect.x = 0; fullRect.y = 0; bool oldEnabled = GUI.enabled; GUI.enabled = false; // Walk backwards to find how many previous frames we need to show. int maxContextFramesToShow = m_Window.IsRecording() ? 1 : 3; int numContextFramesToShow = maxContextFramesToShow; int currentFrame = frameDataView.frameIndex; float currentTime = 0; do { int prevFrame = ProfilerDriver.GetPreviousFrameIndex(currentFrame); if (prevFrame == -1) { break; } iter.SetRoot(prevFrame, 0); currentTime -= iter.frameTimeMS; currentFrame = prevFrame; --numContextFramesToShow; }while (currentTime > m_TimeArea.shownArea.x && numContextFramesToShow > 0); // Draw previous frames while (currentFrame != -1 && currentFrame != frameDataView.frameIndex) { iter.SetRoot(currentFrame, 0); DoProfilerFrame(currentFrame, fullRect, true, threadCount, currentTime); currentTime += iter.frameTimeMS; currentFrame = ProfilerDriver.GetNextFrameIndex(currentFrame); } // Draw next frames numContextFramesToShow = maxContextFramesToShow; currentFrame = frameDataView.frameIndex; currentTime = 0; while (currentTime < m_TimeArea.shownArea.x + m_TimeArea.shownArea.width && numContextFramesToShow >= 0) { if (frameDataView.frameIndex != currentFrame) { DoProfilerFrame(currentFrame, fullRect, true, threadCount, currentTime); } iter.SetRoot(currentFrame, 0); currentFrame = ProfilerDriver.GetNextFrameIndex(currentFrame); if (currentFrame == -1) { break; } currentTime += iter.frameTimeMS; --numContextFramesToShow; } GUI.enabled = oldEnabled; // Draw center frame last to get on top threadCount = 0; DoProfilerFrame(frameDataView.frameIndex, fullRect, false, threadCount, 0); GUI.EndClip(); // Draw tooltips on top of clip to be able to extend outside of timeline area DoSelectionTooltip(frameDataView.frameIndex, m_TimeArea.drawRect); }