XRPushButton "doesn't work" if parent object is moved
ddmck opened this issue · comments
When using the XRPushButton from within a parent gameobject that moves the button seems unresponsive. This is because in the OnStart function m_BaseButtonPosition is set, so the hover logic is basing its calculation on the initial position of the button, so it does "work" but only if you position your hand in the initial location.
I fixed my issue by updating
var localOffset = transform.InverseTransformVector(interactorTransform.position - m_BaseButtonPosition);
to
var localOffset = transform.InverseTransformVector(interactorTransform.position - m_Button.position);
in Unity.XR.Content.Interaction\Assets\XRI_Examples\UI_3D\Scripts\XRPushButton.cs
I realize this might incur performance penalties. I'm also pretty new to Unity so I might be misunderstanding things like the distance calculation mode.
Maybe a best of both worlds approach would be a toggle that enables the user to set the button as static or movable?