Unity test tools and SteamVR plugin, suppress "no hmd" error when running tests

I created an empty project in 5.4, imported SteamVR and Unity Test tools. I created a scene added an integration test to it. When I run the test I get the following error:

I do not have Hmd connected, because I am running a test. The test runs, but I get the error messages in the log. What can I do to so that these errors do not show up?

Thanks.

Hey,

In Edit > Project Settings > Player
look for “Virtual Reality SDKs”. Click on “+” And add “None”. Move it to first place.

On your main menu (or someplace else) check if the HMD is connected.
I personally tried to use “Valve.VR.OpenVR.IsHmdPresent()”. But this method also tries to turn it on and it gets stuck in an endless initialization loop (continuously spitting out the same error you mentioned).

What I did was the following:

Valve.VR.EVRInitError error = 0;
Valve.VR.OpenVR.Init(ref error);

if (error != Valve.VR.EVRInitError.None)
{
       //tell the user to connect their hmd
}
else
{
       //turn it on
        VRSettings.LoadDeviceByName("OpenVR");         
}

Obviously this is only an example and you should check for specific errors instead of checking for any error. In this case if the HMD is connected and SteamVR is turned off, it’s going to turn it on for you.

This will allow you to set up your scene and avoid calling SteamVR stuff when you’re not supposed to!

4 Likes