Unity SDK - Check if hardware is SR capable

Hey everyone,

My company has been testing Leia SR with some decent success and wants to move forward with development. We are currently determining the best design for supporting both SR and standard development branches.

Is there an easy way to determine if the current hardware is SR capable? Best I can find is using the SRUnity. SRInternalPlatform.GetSimulatedRealityRuntimePath() which is empty if the SR platform is not installed. This option, however, isn’t ideal since, I would assume, you could install the SR platform without actually having compatible hardware. Is there a way to check the SR platform connection state so that we can fallback on the standard when needed?

Thanks for your time!

Hello Marcus,

Currently, we do not have a straightforward method to determine whether the SR display is connected in our Unity plugins. However, we do have a feature in our Windows Core SDK that can identify the connection state, and we are planning to implement this feature in our Unity Plugin as well. In the meantime, here’s a workaround to identify whether the SRDisplay is connected: by obtaining an eye position and comparing it with the default value, once the SRContext is established. This will check if the SR display is connected by verifying the functionality of the eye connection. Below is a snippet of code that demonstrates this approach.

Thanks.

bool isSRDisplayConnected;
bool hasCheckedSRStatus;

    void Update()
    {
        if (!hasCheckedSRStatus)
        {
            CheckSRStatus();
        }
    }

    private void CheckSRStatus()
    {
        if (SRInternalPlatform.GetSimulatedRealityRuntimePath() == null)
        {
            Debug.Log("SRPlatform is not installed");

            hasCheckedSRStatus = true;
        }
        else
        {
            if (SRCore.Instance.GetSrContext() != IntPtr.Zero)
            {
                if (SREyes.GetDefaultEyePositionCM() != SRUnity.SRHead.Instance.GetEyePosition(ISRSettingsInterface.GetProjectSettings(null)))
                {
                    isSRDisplayConnected = true;
                    Debug.Log("SRDisplay is connected");
                }
                else
                {
                    isSRDisplayConnected = false;
                    Debug.Log("SRDisplay is not connected");
                }

                hasCheckedSRStatus = true;
            }
        }
    }
2 Likes