# TryGetStat(IntegratedSubsystem, string, out float)

> Retrieve a statistic for an XR subsystem.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.XR.Provider](/engine/6000.5/script-reference/unityengine/xr/provider.md)
* **Assembly:** UnityEngine.XRModule

## TryGetStat(IntegratedSubsystem, string, float)

```csharp
public static bool TryGetStat(IntegratedSubsystem xrSubsystem, string tag, out float value)
```

### Parameters

**** (\[IntegratedSubsystem]\(/engine/6000.5/script-reference/unityengine/integratedsubsystem)): The subsystem with which the stat is registered.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The tag used to query for a statistic.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Receives the current value of the requested statistic. Contains a valid value when this method returns true.

### Returns

| Type                                                          | Description                                                     |
| ------------------------------------------------------------- | --------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True, if the requested statistic is available, false otherwise. |

### Remarks

The TryGetStat method queries an XR subsystem for the specified statistic and, if available, sets the output `value` parameter to the current statistic value. TryGetStat returns true to indicate that the output parameter contains a valid statistic value. If the specified tag is not defined for the subsystem or the subsystem itself is not ready, TryGetStat returns false.

### Examples

```csharp
using UnityEngine.XR.Provider;
using System.Collections.Generic;
using UnityEngine.XR;
using UnityEngine;
using XRStats = UnityEngine.XR.Provider.XRStats;

public static class OpenVRStats
{
    public static float GPUFrameTime()
    {
        float tmp;
        XRStats.TryGetStat(GetFirstDisplaySubsystem(), "OpenVR.Display.GPUFrameTime", out tmp);
        return tmp;
    }

    public static float MotionToPhoton()
    {
        float tmp;
        XRStats.TryGetStat(GetFirstDisplaySubsystem(), "MotionToPhoton", out tmp);
        return tmp;
    }

    // etc...
    private static IntegratedSubsystem GetFirstDisplaySubsystem()
    {
        List<XRDisplaySubsystem> displays = new List<XRDisplaySubsystem>();
        SubsystemManager.GetInstances(displays);
        if (displays.Count == 0)
        {
            Debug.Log("No display subsystem found.");
            return null;
        }
        return displays[0];
    }
}
```
