Hi, I just was curious if this was even possible?
You can read data from a slider, either directly or via the OnValueChanged.
You can assign data to an InputField, as documented.
What part are you having difficulty with?
I don’t see a way to drag the inputfield into the sliders onvaluechanged, and then set the inputfield to equal the slider value.
I want the field to show what the slider value is.
I wasn’t sure if I needed an extra script for this, or if I could set it up through the slider’s onvaluechanged section. I expected to see like a dynamic string when I dragged in the field, but there isn’t anything there. I’m sorry if this is confusing, I wasn’t sure if it could be done or not.
Edit: I see the text parameter for the input field is static. I assume this means it can’t be done by simply dragging it in, I’ll need to write a function for it.
I found a way. I wrote this script that derives from InputField and has a function I can use in the slider as a dynamic string.
using UnityEngine.UI;
public class InputFieldExtension : InputField {
public void Text(string s) {
text = s;
}
public void Text(int i) {
text = i.ToString();
}
public void Text(float f) {
text = f.ToString();
}
}
That is pretty clever!
I would have just done the gather-slider value, shovel it to input field… but hey, if that works, more power to you.