MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Rotating pinch slider shifts position of Thumb

Open SakaITa opened this issue 6 years ago • 3 comments

Describe the bug

If you rotate the PinchSlider after launching the application, the Thumb shifts to the side.

To reproduce

  1. Open 'SliderExample' scene in MRTK Examples
  2. Rotate 'PinchSliderColorRed' on Scene Window
  3. Grabbing slider
  4. Thumb shifts to side

Expected behavior

Thumb does not move sideways when rotating.

Screenshots

shifts_position_of_thumb

Your setup (please complete the following information)

  • Unity Version 2019.4.9f1
  • MRTK Version v2.51

Target platform (please complete the following information)

  • HoloLens 2

SakaITa avatar Oct 28 '20 04:10 SakaITa

Verified, when the scene is rotated (you can do this by grabbing the title bar of the description panel), then when you pinch and move the slider thumb, it shows the shift. 2020-11-03 15_33_31-MRTK250 - HandInteractionExamples - Android - Unity 2019 3 13f1 Personal DX11 2020-11-03 15_34_09-MRTK250 - HandInteractionExamples - Android - Unity 2019 3 13f1 Personal DX11

cre8ivepark avatar Nov 03 '20 06:11 cre8ivepark

I can also confirm this. The same behavior can be reproduced regardless of the axis used in the PinchSlider.cs script.

FFSchier avatar Jan 21 '21 19:01 FFSchier

Current workaround: Only change the thumbRoot local Position.

  1. Calculate newSliderPos in the given UpdateUI() method via:
var newSliderPos = GetSliderAxis() * (sliderValue - .5f) * Vector3.Distance(SliderStartPosition, SliderEndPosition); 
// ChosenSliderAxis * (sliderValue-.5) * Distance between start and end points (sliderThumbOffset should not be needed here.) 
// -.5f needed to allow 0 be the center of the slider track.
newSliderPos += initialLocalThumbRootPosition; // adding the initial Position of the ThumbRoot to position it on the slider.
thumbRoot.transform.localPosition = newSliderPos;
  1. After storing the initial thumbRoot Position in start before initializing it via InitializeSliderThumb()
            initialLocalThumbRootPosition = thumbRoot.transform.localPosition;

... not as pretty - but it allows to

  • rotate the object or any of its parents
  • change SliderAxis on runtime (need to re-run visuals, or slider position only updates correctly on first interaction.)
  • while keeping the rest untouched.

Hope this helps anyone if their experiencing this issue before 2.6! 🚀

FFSchier avatar Jan 22 '21 11:01 FFSchier