4.6 Slider round to int?

So I am using a slider for audio and as you know the volume has to be from 0-1. so what I did was do this:

MusicTxt.text = “” + MusicSlider.value * 100;

Now my question is, can I make it a whole number instead of the decimals on the end, if so how?

There are two ways:

  1. You can directly set the values to be integer for the slider by checking the ‘Whole Numbers’ checkbox and then setting the min and max values to be 0 and 100. This will allow to choose values that are only integer values between 0 and 100 so you do not need to multiply the slider value by 100.

  2. With your current code:

    MusicTxt.text = “” + (int) MusicSlider.value * 100;