- Home /
How do I get a UI Slider to provide a value with OnValueChanged?
I'm trying to use a slider as a throttle, I've already pointed it towards the script I'm using as a control panel, and told it to invoke some arbitrary throttle function:
public void ChangeThrottle(float newSetting) { desiredThrottleSetting = newSetting; }
Since it's public, it's trivial to call this from the slider:
However, On Value Changed apparently wants me to input the value manually, and the entire point of using a slider was to let its value inform the throttle; can I somehow change how I'm using On Value Changed, and point it at the slider's value instead of manually inputing a number?
Answer by callme · Nov 15, 2016 at 02:55 AM
sorry if i get it wrong. To change slider value you need like this
public Slider slid;
Assign slid manualy or in start func:
slid = getcomponent...
and now use slid.value = .5f;
desiredThrottleSetting = slid.value;
OnValueChanged calls automatic when you change Slider Value.
Your answer

Follow this Question
Related Questions
add delegate to toggle in unity 4.6 UI 2 Answers
UI toggle.onValueChanged assigning method via script 1 Answer
Problem with onClick.AddListener 1 Answer
Runtime Click Listener Addition 0 Answers
Unity UI dynamic Buttons 4 Answers