I have UI Slider and under OnValueChanged, I picked a camera’s orthographic size. So when the slider value is changed, it changes camera’s size. But the slider’s initial value stays whatever it is set in the editor. I want the initial value of the slider to be set to the camera’s size. How can I use the variable I picked in editor under OnValueChanged to set the starting value of the slider? I am looking for a more generic solution because I will have multiple sliders, each will pick a different variable to change. O do I really have to write a script for each occasion?
I want the chosen variable (as in the screenshot) to be used to set the initial value.
set the slider value in awake or start
How about:
public Slider[] sliders;
public float[] values;
void Start()
{
for (int i = 0; i < sliders.length; i++;)
{
sliders_.value = values*;*_
}
}
This way, you only need one script, to manage the start value of all your sliders. @metinevren