public void OnTextInputChanged(string value) { if (!servo) { return; } //angle variable life cycle starts here float angle; //Converts the string representation of a number to its 32-bit signed integer equivalent. //A return value indicates whether the conversion succeeded. if (float.TryParse(value, out angle)) { if (angle > maxAngle || angle < minAngle) { angle = Mathf.Clamp(angle, minAngle, maxAngle); input.text = angle.ToString(); } servo.SetAngle(angle); prevValue = input.text; if (slider.value != angle) { slider.value = angle; } } else { input.text = prevValue; } }