I am using Unity's slider to set a floating point number between the ranges of 1.0 - 10.0. The problem is, it rounds off. I do not want the slider to round off the value, instead it should display as it is. Can you please help me fix this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
private Slider sliderUI;
void Start () {
sliderUI = GetComponent<Slider> ();
sliderUI.value = 3.56f;
}
The slider value changes to 3.6. How do I make it 3.56?
CodePudding user response:
I think it only rounds it on the inspector, the component should have the value you give it.
Try adding an Update
with Debug.Log(sliderUI.value);
If it is showing 2.6
you have a real problem, if it shows 2.56
then is just a visual for the inspector.
CodePudding user response:
Not quite sure, but maybe you need to set the minimum to 1.00 and the maximum to 10.00 instead of 1.0 and 10.0 ot just 1 and 10.