0

I'm trying to get dropped frames count on build and I'm using this method https://docs.unity3d.com/ScriptReference/XR.XRStats.TryGetDroppedFrameCount.html in order to do it. It constantly returns false meaning that dropped frames count is not availible and I cannot find any information on how to make it availible. Does anyone know how to get dropped frames count in Unity? I'm using OpenXR SDK and Occulus Quest 2 as a target device. My Unity version is 2021.3.14f1.

The code that I am using:

using UnityEngine;

using Unity.Profiling;

using TMPro;

using UnityEngine.XR;

[RequireComponent(typeof(TMP_Text))]
public class StatsPrinter : MonoBehaviour
{
        private TMP_Text statsText;

        private ProfilerRecorder batchesGetter;
        private ProfilerRecorder setPassGetter;
        private ProfilerRecorder vertsGetter;
        private ProfilerRecorder trisGetter;
        
        void Start()
        {
            statsText = GetComponent<TMP_Text>();
    
            batchesGetter = ProfilerRecorder.StartNew(ProfilerCategory.Render, "Batches Count");
            setPassGetter = ProfilerRecorder.StartNew(ProfilerCategory.Render, "SetPass Calls Count");
            vertsGetter = ProfilerRecorder.StartNew(ProfilerCategory.Render, "Vertices Count");
            trisGetter = ProfilerRecorder.StartNew(ProfilerCategory.Render, "Triangles Count");
        }
    
        void Update()
        {
            if (batchesGetter.LastValue > 0)
            {
                statsText.text = $"Batches: {batchesGetter.LastValue}\n";
                statsText.text += $"SetPass Calls: {setPassGetter.LastValue}\n";
                statsText.text += $"Vertices: {vertsGetter.LastValue}\n";
                statsText.text += $"Triangles: {trisGetter.LastValue}\n";
                if (XRStats.TryGetDroppedFrameCount(out int droppedFrames))
                    statsText.text += $"FramesDropped: {droppedFrames}\n";
            }
        }
    }

0 Answers0