- Home /
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;
}
}
}
Answer by tormentoarmagedoom · Mar 12, 2018 at 12:32 PM
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 have tried to duplicate it but I can't seem to do so. When I try and edit the slider script I am unable to.
read this post. Is about buttons scripts, but i supose its the same
I have read the post, but it doesn't seem to provide a solution to my issue.
Answer by davejones1 · Mar 12, 2018 at 11:07 PM
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
Answer by adem_rodriguez · May 28, 2021 at 11:25 AM
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 ;)