On start the slider value doesn´t match the real value

I mean, the default values of both sliders were 0 but the values in the editor start as 1 for volume and as 1 for intensity. 

When hitting play those values are the ones applied to the scene. 

Once the sliders are modified the values get updated. 

I wonder, what is the proper way to init the slider to the actual value? 

i found that changing the event properties from "runtime only" to "editor and runtime" cause both to sync up in the editor. But what happens after the game is build? does it needs a script? 




  • Jonathan Gonzalez(jgonzalez) replied

    In the video we just used the audio component directly, in order to start off with a given value we'd need to use a script. In the script you'd get the default value of the audio then assign that as the value to the slider from the Start or Awake method. Then you'd have another method that updates the audio value based on the slider value. So essentially you set the value to the slider initially then the slider sets the value of whatever you'd want to change afterward. 

  • Jonathan Gonzalez(jgonzalez) replied

    Oh I forgot to mention, this method I mentioned in my original answer is actually covered in the second chapter of this course. Look at the "Scripting UI" lesson, you'll see how to script the value of the slider initially. 

  • Jose Miguel Hernandez(jmiguelhdezgmailcom) replied

    Thanks, i have a few lessons left before "Scripting UI" but i will look at it soon :)