Hi!
I am not sure I`ve got idea of all this code.
But my sliders does not use last visual step.
To reproduce that set Number of steps to 5 and try to set maximum - you will never get amout=1, maximum will be amout=0.8.
So I replaced it with such simple snapping.
if (numberOfSteps > 0)
{
// float valueSeparation = 1f / (float) numberOfSteps;
// float nearestValue = 0f;
// while (nearestValue < visualAmount)
// {
// nearestValue += valueSeparation;
// }
//
// // Now larger than amount, so which is closer?
// float lowerNearest = nearestValue - valueSeparation;
// if (visualAmount - lowerNearest > nearestValue - amount)
// {
// visualAmount = nearestValue;
// }
// else
// {
// visualAmount = lowerNearest;
// }
visualAmount = Mathf.Round(visualAmount * numberOfSteps) / numberOfSteps; // Use the Math Force Luke
}
Comments