private static bool OpenProfileData(int instanceID, int line) { var assetPath = AssetDatabase.GetAssetPath(EditorUtility.InstanceIDToObject(instanceID)); if (System.IO.Path.GetExtension(assetPath) != ".data") { return(false); } PerformanceTrackerActions.OpenProfileReport(assetPath, "", Analytics.ActionSource.OpenAsset); return(true); }
private void EndTrackerProfiling(Button btn, string trackerId) { m_CurrentProfileTag = String.Empty; UpdateActionButton(btn, trackerId); PerformanceTrackerActions.StopProfilerRecordingAndCreateReport(trackerId, Analytics.ActionSource.PerformanceTrackerWindow); }
private VisualElement MakeItem() { var row = new VisualElement(); row.style.flexDirection = FlexDirection.Row; row.AddToClassList("perf-row"); var pinIcon = new VisualElement(); pinIcon.AddToClassList("perf-pin"); row.Add(pinIcon); var trackerName = new TextField { isReadOnly = true }; VisualElement column = trackerName; column.AddToClassList("perf-tracker-name"); row.Add(column); if (IsColumnVisible(ColumnId.SampleCount)) { column = new Button(); column.RegisterCallback <MouseUpEvent>(evt => { var tracker = GetTrackerInRowAtEvt(evt); EditorPerformanceTracker.Reset(tracker.name); RefreshTrackers(); SendAnalytics(Analytics.WindowUsageType.ResetSampleCount, tracker.name); }); column.AddToClassList("perf-sample-count"); row.Add(column); } if (IsColumnVisible(ColumnId.Age)) { column = new Label(); column.AddToClassList("perf-age"); row.Add(column); } if (IsColumnVisible(ColumnId.AvgTime)) { column = new Label(); column.AddToClassList("perf-avg-time"); row.Add(column); } if (IsColumnVisible(ColumnId.PeakTime)) { column = new Label(); column.AddToClassList("perf-peak-time"); row.Add(column); } if (IsColumnVisible(ColumnId.LastTime)) { column = new Label(); column.AddToClassList("perf-last-time"); row.Add(column); } if (IsColumnVisible(ColumnId.TotalTime)) { column = new Label(); column.AddToClassList("perf-total-time"); row.Add(column); } var actionBtn = new Button { text = "..." }; actionBtn.RegisterCallback <MouseUpEvent>(evt => { var btn = evt.target as Button; var tracker = GetTrackerInRowAtEvt(evt); if (tracker.name == m_CurrentProfileTag) { EndTrackerProfiling(evt.target as Button, tracker.name); } else { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Set as search filter"), false, () => { m_SearchField.value = tracker.name; SendAnalytics(Analytics.WindowUsageType.SetSearchFieldAction, tracker.name); }); menu.AddItem(new GUIContent("Add performance notification"), false, () => PerformanceTrackerActions.AddNewPerformanceNotification(tracker.name, (float)tracker.avgTime, Analytics.ActionSource.PerformanceTrackerWindow)); menu.AddItem(new GUIContent("LogCallstack"), false, () => PerformanceTrackerActions.LogCallstack(tracker.name, Analytics.ActionSource.PerformanceTrackerWindow)); if (String.IsNullOrEmpty(m_CurrentProfileTag)) { menu.AddSeparator(""); menu.AddItem(new GUIContent("Editmode Profile..."), false, () => StartTrackerProfiling(btn, tracker.name, false, true)); menu.AddItem(new GUIContent("Editmode Deep profile..."), false, () => StartTrackerProfiling(btn, tracker.name, true, true)); menu.AddSeparator(""); menu.AddItem(new GUIContent("Playmode Profile..."), false, () => StartTrackerProfiling(btn, tracker.name, false, false)); menu.AddItem(new GUIContent("Playmode Deep profile..."), false, () => StartTrackerProfiling(btn, tracker.name, true, false)); } menu.ShowAsContext(); } }); actionBtn.AddToClassList("perf-actions"); row.Add(actionBtn); return(row); }