Is there a way to set the amount a sliders value changes when you use it? - unity3d

I'm am trying to make it so that when you interact with a slider, it goes up or down by 5. I know you can make it go up in whole numbers but can you change the base value that it increases/decreases by?

Not a built-in feature unfortunately. The workaround is to enable Whole Numbers, and set:
Slider min = Actual min / Step
Slider max = Actual max / Step
Then in your code you can do Actual value = Slider value * Step
Or you can write your own slider component with stepping support.
PS: I know, it sucks.

Related

Map step to linear scale more than 100 with MUI Slider

I'm using MUI slider, and I'm at a loss how to create a slider with mapping for values more than 100. Apart from creating all 180 days in the mark array and restricting the values, is there another way to do it? I was hoping to be able to set something like step={1} and stepLength={100/180} which will give the distance travelled on the line per step (signifying one day).
I have this codesandbox with my not-working-correctly example.
Just had this same problem. Add
max={180}
In your
<Slider
...
min={0}
max={180}
...
/>
Then change the values under your labels inside of
const Marks = [...];
To get your desired output!
If you want to add a side button to increment by a certain amount, MUI also has an input field option.

How to make the set of possible values for UISlider an open interval?

I am using a UISlider to allow a user to choose among four options. I ask the user a question of the form "how much do you like this thing?", they respond by moving the slider, and then behind the scenes I map the value of the slider to one of four elements of an array. I want the first quarter of the slider to correspond to the first element of the array, the second quarter of the slider to correspond to the second element of the array, and so on.
By default, the range of a slider is [0,1], so one natural way to do what I want is:
let index = Int(rangedSlider.value * Float(currentAnswers.count) )
assuming that rangedSlider is the name of the outlet connected to the UISlider in question, and currentAnswers is the array of answers I'm mapping to. The issue with this is that if the user moves the slider all the way to the right, that sets the value of the slider to 1, which maps to index 4 by the formula above (assuming there are four answers). I can always add an additional line of code that takes care of that case separately,
if rangedSlider.value == 1 { index = currentAnswers.count - 1 }
but I prefer a one line solution.
I can also set the max value of the slider to 0.99 in the Storyboard and stick with the first line of code I wrote, but I want to know: is there a built-in way to make the range of UISlider values an open interval? Is there a better way to get the behavior I want?
Is this any more complicated than:
let index = Int(rangedSlider.value * Float(currentAnswers.count - 1))
Or have I misunderstood the problem you're having?
That way your index will be returned as a number between 0 and 3 with 0 corresponding to the first answer and 3 corresponding to the fourth answer.

How to use a range instead of a single value for an axis tick in Tableau?

I don't want to mess with the graph itself, but I want to change the axis tick so that it reads a different value. Right now my axis looks like 0, 1, 2, 3....24. I want it to look like: 0-1,1-2,3-4...23-24.
Is it possible to just change the text without changing my graph?
Thanks in advance!
One way to implement this would be by converting your column in to a discrete value and changing the alias for value 0 to 0-1, 1 to 1-2... and so on.
Hope this helps.
Another option is to create a calculated field and return the range based on the values. This gives you more control if you would like customize your range in the future. There will be an issue with sorting which you will need to work out.

Slider settings for GPUImage

I'm making an app which allows the user to apply GPUImage filters to still photos using a UISlider. I'd like for the slider to initially start at the zero point for each filter (i.e. the value at which none of the filter has been applied yet) and I'm wondering how this can be determined? I've used some of the values that are listed in the GPUImage documentation and for certain sliders they start at 0, but others it's hard to determine (and for some, the min and max values are way off for me). The values for something like GPUImagePosterizeFilter seem to be way off for me (set min to 1, max to 128 and initial to 1). I've also checked some of the values in the FilterShowcase test project which are different than the documentation, but still don't always start at 0. Am I just completely missing the point here? Or is there some setting I maybe have to turn on to be in line with the slider values?
Nope, no setting for this. All I can really recommend is that to make this as efficient as possible make a switch statement in a single method and determine what to do by index of the currently selected filter.
From there, I would leave the min/max values of the slider the same so that you don't have to animate from one calculated point to another if the filter changes and mathematically convert the slider's value into units that the current filter understands. i.e. 0-1 --> 1-128
I think I might have been approaching this the wrong way. Rather than looking for a "zero point" on a filter, I think I should focus on applying the filter only when the user applies it, and trying to find a good starting point that is close to how the image looks without the filter for the initial value on the slider.

how to fix interval on UISlider,iphone

I have Slider,which works perfect.
But what i am trying to do is,
for ex, min =0 and max=50 and x=0
every time i slide or use buttons to change the value of slider, the interval should be of 5 only.
i.e x should be equal to only 0,5,10,15.....50
Suggestions.
Thanks
In the callback (value changed) - read the value, round it up or down to the nearest increment of 5, then set the slider to your preferred value. That way, it will 'jump' between your preferred values.