Hello,
I have 5 sliders and their values. The value decrease (not at the same speed). I want to know which slider has the smallest value. could you help me ?
I think the simplest way would be to use a public array to assign those sliders from the inspector:
// This array is accessible from the inspector
public Slider[] sliders;
Go back to your inspector and assign the Size
to 5
, then select the sliders you want to compare. You can then get the slider with the smallest value by using something like:
// Use the public array above
public Slider CheckSmallestSlider ()
{
Slider minSlider = this.sliders [0];
for (int k = 1; k < this.sliders.Length; k++) {
if (minSlider.value > this.sliders [k].value)
minSlider = this.sliders [k];
}
return minSlider;
}
I’ll attach the full script in a comment to this.