From the profiler window, I want to be able to copy as text: the call stack starting from a method up to the “root” method, including the duration of each method.
Is it possible to “hook” into this tooltip feature (shown below) so that i could add the timestamps to the call stack list?
i.e., currently it gives me:
AssetDatabase.V2.RefreshInternal
Application.Reload
MonoCompiler.Tick
Application.Tick
EditorLoop
But I want:
AssetDatabase.V2.RefreshInternal 2500ms
Application.Reload 1000ms
MonoCompiler.Tick 800ms
Application.Tick 400ms
EditorLoop 100ms
You can’t currently hook into that particular copy UI, but you could write an editor script (and even hook that up to a shortcut via the ShortcutManager or by making it a Menu entry, which automatically makes it available in the ShortcutManager) that copies the information you want to your clipboard.
For that, you’d wanna be using these APIs:
- ProfilerWindow.GetFrameTimeViewSampleSelectionController
- Profiling.IProfilerFrameTimeViewSampleSelectionController.selection
- ProfilerWindow.selectedFrameIndex
- ProfilerTimeSampleSelection
- And the FrameDataViews (Raw or Hierarchy depending on if you want to step from the selected sample backwards in time to find the path to the root sample but only get the sample stack and timings of exactly the selected stack shown in Timeline, or if you’re fine going the easy route and taking the collapsed (though that is an option) and already hierarchically organized data structure so you can just go from a precise (or shared/collapsed by shared name and sample stack) sample through all its parent samples)