Read frame timing data with ProfilerRecorder
Get frame time data using the ProfilerRecorder instead of the FrameTimingManager API.
Read time 1 minuteLast updated 20 days ago
You can use the API to get custom and built-in Profiler counter values, and to read values.
ProfilerRecorderFrameTimingManagerThe benefit of this is that when you use the API, only records values when you attach a recorder to a specific counter. This behavior enables you to control which counters collect data and reduces the impact that the has on performance.
ProfilerRecorderFrameTimingManagerFrameTimingManagerThe following example tracks only the CPU Main Thread Frame Time variable with the API:
ProfilerRecorderusing Unity.Profiling;using UnityEngine;public class ExampleScript : MonoBehaviour{ ProfilerRecorder mainThreadTimeRecorder; void OnEnable() { mainThreadTimeRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Internal, "CPU Main Thread Frame Time"); } void OnDisable() { mainThreadTimeRecorder.Dispose(); } void Update() { var frameTime = mainThreadTimeRecorder.LastValue; // Your code logic here }}