Forum rules - please read before posting.

Bug In sliders - last visual step is not used.

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

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.