Is it possible to take the value entered in an InputField and have it adjust a slider?
If yes, how can it be done? The input field value is a text value and the slider value is a float.
Yes. There is a method Single.Parse that you can use to convert a string to a float.
After that it’s just a case of assigning the value to the slider.
That worked, thank you!
cameraFovCurVal = System.Single.Parse(CameraFOVInputField.GetComponent<UnityEngine.UI.InputField>().text);
You might also want to consider TryParse or wrap it in some logic to prevent the user typing in “Fred” and breaking your code.
1 Like
Or change the content type to decimal number
Discovered that part… had it changed to integer. Thank you both.