How to detect if a user is wearing the HMD¶
The CommonUsages.userPresence is no longer supported in VIVE Wave™ Unity plugin. Please use InputSystem.ProximitySensor instead.
Here is the sample code for detecting the user’s presence.
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
#if UNITY_ANDROID && ENABLE_INPUT_SYSTEM
public static bool IsUserPresence()
{
if (ProximitySensor.current != null)
{
if (!ProximitySensor.current.IsActuated())
InputSystem.EnableDevice(ProximitySensor.current);
return ProximitySensor.current.distance.ReadValue() < 1; // near p-sensor < 1cm
}
return false;
}
#endif