Slider maxValue Question.

Hey guys, i’ve got a question about the maxValue on the UI slider component. I want to change the sliders max value to equal the length of an audioclip. I made it so the slider maxValue is equal to the audiosource.clip.length, and no errors there! However in the inspector it still has its values to 1 for the max. I want to make a bunch of these off of other audioclip lengths so im wondering if theres a way to disable the maxValue in the inspector or something like that. Thank you so much!

Heres the code for it if you need it:

{
    public AudioSource audioSource;
    public Slider audioSlider;

    // Start is called before the first frame update
    void Start()
    {
        audioSlider.direction = Slider.Direction.LeftToRight;
        audioSlider.minValue = 0;
        audioSlider.maxValue = audioSource.clip.length;
    }

    // Update is called once per frame
    void Update()
    {
        audioSlider.value = audioSource.time;
    }
}

I just put it together your code with a quick test rig and everything is working after entering play mode as it should be.

7053082--837016--screenshot1.png

1 Like

Weird. Maybe I messed up a setting somewhere. Thank you for testing that for me! I appreciate your time!