- Home /
Round if end's in 0
I have an input field with a value assigned by a slider, i need that when the input field take a value for example 15.00 or 15.0 it's get rounded to 15, i need to delete that 0. And if it finish in whatever other value dont get rounded, How can i done this? i'm using this little piece of script to set the value of the slider to the inputfield
private void SetInputFieldText(float value)
{
m_inputField.text = value.ToString("F2");
}
Answer by panim0_unity · Nov 04, 2021 at 01:09 AM
string.Format("{0:0.0}", value); result value.0 string.Format("{0:0}", value); result value this is one of the ways, can help you out if I understood the question right :) @arth9130
Your answer
![](https://koobas.hobune.stream/wayback/20220613044946im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
"Edit Script" opens UnityEngine.UI.dll instead of the script 0 Answers
I need help with a Controller on a 2D Game for Android with horizontal movement 1 Answer
C# Getting "Cannot cast from source type to destination type" even though it's working. 1 Answer
how can i move a rigitbody relative to its parent 2 Answers
Error on build 2 Answers