PressableButtonHoloLens2 Does Not UpdateMovingVisualsPosition Correctly
Description
The current calculation of the pressPercentage in the method UpdateMovingVisualsPosition() appears to cause faulty behaviour, when the MaxPushDistance is set to a negative value:
float pressPercentage = Mathf.Max(minCompressPercentage, (1.0f - (CurrentPushDistance - startPushDistance) / MaxPushDistance));
In fact, when MaxPushDistance is negative, pressPercentage is always >1 causing the visual to expand rather than compress.
Steps to reproduce
- Add a PressableButtonHoloLens2.prefab to a sample scene
- Adjust the
MaxPushDistancePressableButtonHoloLens2component in the Editor to be negative (but still in a good proportion to PressDistance etc.) - Switch to Articulated Simulated Hands in the MRTK Input Simulation Profile
- Start Play Mode
- Slowly move an Articulated into the button's collider to press it
--> Observe that the
compressableButtonVisualsexpand rather than compress
Expected behavior
The compressableButtonVisuals only compress with a pressing hand, not expand. The following behaviour seems more appropriate:
float pressPercentage = Mathf.Max(minCompressPercentage, (1.0f - (CurrentPushDistance - startPushDistance) / (MaxPushDistance - startPushDistance)));
since this reflects more accurately the percentage of the hand traveling down the pressable path of the button.
Setup
- Unity 2019.3.3f1
- MRTK v2.2.0
Target platform
- HoloLens 2
This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.
This issue has been closed by an automated process because it is stale. If this is still an issue please add a new comment with more recent details and repro steps.