Version: Unity 6.2 Alpha (6000.2)
Language : English
Get frame timing data
Troubleshooting the Frame Time Manager

Record frame timing data

You can read FrameTimingManager values using the ProfilerRecorder API instead of the FrameTimingManager C# API. The benefit of this is that when you use the ProfilerRecorder API, the FrameTimingManager only records values when you attach a recorder to a specific counter. This behavior enables you to control which counters collect data and so, reduce the impact that the FrameTimingManager has on performance.

The following example shows how to track only the CPU Main Thread Frame Time variable with the ProfilerRecordAPI:


using Unity.Profiling;

using UnityEngine;

public class ExampleScript : MonoBehaviour

{

    string statsText;

    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

    }
}

Get frame timing data
Troubleshooting the Frame Time Manager
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961