I found some code to poll the proximity sensor, to know when the HMD is on/off. However I am unsure how to implement - I keep getting the error that the proximity sensor action is not defined in default in actions. Here’s the code:
SteamVR_Input_Sources m_inputSourceDevice = SteamVR_Input_Sources.Any;
if (!isHeadsetOn && SteamVR_Input._default.inActions.Proximity_Sensor.GetState(m_inputSourceDevice))
{
Debug.Log("Headset On.");
//HeadsetOn();
}
else if (isHeadsetOn && !SteamVR_Input._default.inActions.Proximity_Sensor.GetState(m_inputSourceDevice))
{
Debug.Log("Headset Off (cancellable)");
//StartCoroutine(HeadsetOff());
}
I can see the proximity sensor working in the Input Debugger, but I can’t figure out how to add it to default actions like that code snippet suggests.
I tried adding it myself and then I get an all black page when trying to bind it or use the debugger.
Anyone know of a tutorial on this?
The last post has a link to an updated plugin which has proximity sensor available. I haven’t had a chance to check it out yet myself but I think it should work.
I had to manually edit the .json as described in the issue because as of SteamVR 2.2 the proximity sensor is still not exposed in the bindings UI. I spent a lot of time trying to get it to work because I didn’t realize that the “SteamVR Input Live View” built into Unity doesn’t actually show any activity until you try to access that value in code. This is especially confusing because the “Input Debugger” you can launch from the web based bindings UI does show proximity activity. It wasn’t until I added the following code that I saw any activity for “HeadsetOnHead” within the Unity based Live View: