microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

More options for Slider/PinchSlider/StepSlider #10186

Closed andikay closed 9 months ago

andikay commented 3 years ago

I have been working on porting an application to HoloLens 2 and while I was able to make Unity UI buttons and checkboxes work I have not been able to make sliders work at all. (I would love for the Unity UI to just work with HoloLens 2 in general obviously) Therefore, I have been trying to recreate the existing sliders, but the MRTK sliders are lacking a lot of features. It would be great if the MRTK sliders had similar options to the Unity sliders, meaning:

Currently, the MRTK sliders only work with a float from 0 to 1 and the StepSlider has "Slider Step Divisions" which often create very awkward numbers. For example, I want 10 steps from 0 to 1 (including 0 and 1), meaning I need to have 9 "Slider Step Divisions". This creates steps that have the following values:

And this is just a simple example. Imagine creating a slider that should be a setting for horizonal FOV with a range of 60° to 360°, for example. Using floats from 0 to 1 for this task would be even worse.

RogPodge commented 3 years ago

The intention behind the way that the slider currently handles values is to have the developers translate the 0-1 value of the slider itself to the appropriate Min value/Max value representation, though understandably this creates more work on their end of things.

We'll keep this in mind and look to expose the min/max value settings on the slider component itself in our next iteration

andikay commented 3 years ago

Thank you for your reply and for adding a suitable label (I tried but couldn't find it).

The problem with the intention of how it currently works is that values from 0 to 1 can be very very impractical to work with and sometimes create a huge amount of work for the developer.

Coming back to the FOV slider example I mentioned before, imagine having a FOV slider of 90 to 360. This means 270° of FOV and 269 step divisions for the current way this works (by the way, it would be better to set the actual steps instead of step divisions in my opinion). So the math here is 1 / 269 = 0,00371747211895910780669144981413 <= this is one step.

Let's say I want to read the current value and perform something at a certain step, maybe at 120°. With the Unity slider the range would be 90 to 360 and not 0 to 1 and I could just read the current value and perform an action if it hits 120. With the MRTK StepSlider I would need to first calculate the steps and then multiply it by the amount of steps needed to hit 120, which I believe is 30 -> the StepSlider value would be 0,11152416356877323420074349442379. However, I have tried this (if stepSlider.SliderValue == 0,11152416356...) and not all values actually work for some reason, maybe because they are handled as doubles internally and not as floats and the rounding is wrong or something along those lines.

In addition, all StepSlider examples only show values from 0 to 1, so there are no useful real-world examples that show how it could be done properly.

RogPodge commented 3 years ago

You make a very good point regarding the floating points. It's really helpful clarification of the root source of the pain and will help us a lot when working on the next iteration.

Thanks again for the feedback! We'll be sure to improve things for the next iteration of the slider!

IssueSyncBot commented 9 months ago

We appreciate your feedback and thank you for reporting this issue.

Microsoft Mixed Reality Toolkit version 2 (MRTK2) is currently in limited support. This means that Microsoft is only fixing high priority security issues. Unfortunately, this issue does not meet the necessary priority and will be closed. If you strongly feel that this issue deserves more attention, please open a new issue and explain why it is important.

Microsoft recommends that all new HoloLens 2 Unity applications use MRTK3 instead of MRTK2.

Please note that MRTK3 was released in August 2023. It features an all new architecture for developing rich mixed reality experiences and has a minimum requirement of Unity 2021.3 LTS. For more information about MRTK3, please visithttps://www.mixedrealitytoolkit.org.

Thank you for your continued support of the Mixed Reality Toolkit!