How do I change the speed at which the slider moves?

@Daemonhahn @meat5000 @Bunny83 @robertbu @Eric5h5
@whydoidoit @clunk47 @Mike 3 @Aurore @DaveA @tormentoarmagedoom @Azzydude24601 @draber @cmz-neu4590
At the moment the slider can be moved fast and the animation gets played rapidly. I want to limit the speed at which the slider can be moved so that the animation is seen at more suitable speed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class animationcontrol : MonoBehaviour {

public Slider slider;
public Animator animator;
public Text step1p1complete; 

void Start ()
{
	slider.onValueChanged.AddListener (delegate {OnValueChanged ();});


}

private void OnValueChanged()
{
	animator.speed = 0;
	animator.Play("anim1", -1, slider.normalizedValue);

}

public void maxvaluereached()
{
	if (slider.value >= 1) {

		step1p1complete.enabled = true; 

	}
}

}

I never tried, but all elements like sliders, buttons, etc have a script that manage it. When you create a slider via Unity, it adds the slider script to the object.

You can duplicate the script, try to find and change thje speed, and use your modified script with that slider.

But as i said, i’ve never tried it

I realise that no one will know a solution to this problem, however it was worth a punt.@Daemonhahn @meat5000 @Bunny83 @robertbu @Eric5h5 @whydoidoit @clunk47 @Mike 3 @Aurore @DaveA @tormentoarmagedoom @Azzydude24601 @draber @cmz-neu4590

Anyone find a solution to this in 2019?

clamp math on value change?

not sure if it’s what you are looking for , but if whole values box is checked ; you can unchecked from the script on the OnValueChanged Event (work better if you have a button instead of an event) , then increase/decrease the silder.value gradually ( by 0.05f for example ) until it reaches the next whole number :wink:

not sure if it’s what you are looking for @davejones1 , but if whole values box is checked ; you can unchecked from the script on the OnValueChanged Event (work better if you have a button instead of an event) , then increase/decrease the silder.value gradually ( by 0.05f for example ) until it reaches the next whole number :wink:

you can used my code, unfortunately stepSize not public in slider, just will add invoice in onValueChanged:

[Range(0, 1)] 
public float sliderSpeed;

private float m_sliderTimeOfChanged, m_sliderOldValue;
private int m_sliderSetCount = 0, m_sliderCurrentSpeed = 1;
private Slider m_lastChangedSlider;

private void UpdateSliderStepSize(Slider slider)
{
    if (m_lastChangedSlider == slider && Time.time - m_sliderTimeOfChanged < 0.15f)
    {
        m_sliderSetCount++;
        float countForSpeedup = (1.1f - sliderSpeed) * 10;

        if (m_sliderSetCount > countForSpeedup)
        {
            float stepSize = slider.wholeNumbers ? 1 : (slider.maxValue - slider.minValue) * 0.1f;
            
            if (m_sliderOldValue < slider.value)
                slider.SetValueWithoutNotify(slider.value + stepSize * m_sliderCurrentSpeed);
            else
                slider.SetValueWithoutNotify(slider.value - stepSize * m_sliderCurrentSpeed);

            if (m_sliderSetCount > countForSpeedup + countForSpeedup * m_sliderCurrentSpeed * (1.1f - sliderSpeed))
            {
                m_sliderCurrentSpeed++;
            }
        }
        else
        {
            m_sliderOldValue = slider.value;
        }
    }
    else
    {
        m_lastChangedSlider = slider;
        m_sliderSetCount = 0;
        m_sliderCurrentSpeed = 1;
    }
    
    m_sliderTimeOfChanged = Time.time;
}

slider.onValueChanged.AddListener(delegate { UpdateSliderStepSize(slider);});