I tried using the slider component for the first time and immediately some question came up:
I already see this going into a feature request ;)
These questions are probably best filed as issues on the MRTK github page. here's a link to file an issue.
But, answering your questions here for future visitors:
The default PinchSlider
does not provide that functionality, but here is an example of how to do this by extending pinchslider (reference: issue 4140
public class SliderWithSnapPoints : PinchSlider
{
[SerializeField]
[Tooltip("The number of snap points")]
float snapPoints = 100;
float lastSnapPoint;
float snapPointSize;
public override void OnPointerDown(MixedRealityPointerEventData eventData)
{
base.OnPointerDown(eventData);
if (eventData.used)
{
lastSnapPoint = SliderValue;
snapPointSize = 1f / snapPoints;
}
}
/// <summary>
/// Handle slider value changes by dragging, and commit these changes.
/// </summary>
/// <remarks>
/// Note, this requires the MRTK pinch slider to implement this function signature,
/// and the pinch slider needs to call this function instead of instead setting SliderValue
/// directly.
/// </remarks>
protected override void OnPointerDragged(float newSliderValue)
{
var valueChange = Mathf.Abs(lastSnapPoint - newSliderValue);
if (valueChange >= snapPointSize)
{
lastSnapPoint = SliderValue = newSliderValue;
}
}
}
You can just delete or disable the tick marks in the scene hierarchy.
The visuals do not adjust because they are not tied to the number of snap points, they are just provided for visual guidance.